掌握各大联赛、杯赛比分,一手掌握球场风云! 实时比分 联赛 主队 比分 客队 时间 即将开赛 联赛 主队 比赛时间 客队 <script> // 假设有获取比分的 APIfunction getScores() {return {"Premier League": [{"homeTeam": "曼联","awayTeam": "利物浦","score": "2:1","time": "2023-03-05 23:00"},// ... 更多比赛数据],"La Liga": [// ... 西甲数据],// ... 其他联赛数据};}// 通过 JavaScript 动态填充表格数据function fillTable(data) {let realTimeTable = document.querySelector("table:nth-of-type(1) tbody");let upcomingTable = document.querySelector("table:nth-of-type(2) tbody");for (let league in data) {// 实时比分 data[league].forEach(match => {let row = document.createElement("tr");let leagueCell = document.createElement("td");let homeCell = document.createElement("td");let scoreCell = document.createElement("td");let awayCell = document.createElement("td");let timeCell = document.createElement("td");leagueCell.textContent = league;homeCell.textContent = match.homeTeam;scoreCell.textContent = match.score;awayCell.textContent = match.awayTeam;timeCell.textContent = match.time;row.appendChild(leagueCell);row.appendChild(homeCell);row.appendChild(scoreCell);row.appendChild(awayCell);row.appendChild(timeCell);realTimeTable.appendChild(row);});// 即将开赛data[league].forEach(match => {let date = new Date(match.time);if (date.getTime() > new Date().getTime()) {let row = document.createElement("tr");let leagueCell = document.createElement("td");let homeCell = document.createElement("td");let timeCell = document.createElement("td");let awayCell = document.createElement("td");leagueCell.textContent = league;homeCell.textContent = match.homeTeam;timeCell.textContent = match.time;awayCell.textContent = match.awayTeam;row.appendChild(leagueCell);row.appendChild(homeCell);row.appendChild(timeCell);row.appendChild(awayCell);upcomingTable.appendChild(row);}});}}// 请求 API 并填充数据window.onload = function() {fetch('https://your-scores-api.com/api/scores').then(res => res.json()).then(data => fillTable(data)).catch(err => console.error(err));}; </script>