script.js
javascript
(function() {const API_URL = 'http://localhost:8080/api/v1/matches';const matchesEl = document.getElementById('matches');function updateMatches() {fetch(API_URL).then(res => res.json()).then(data => {matchesEl.innerHTML = '';data.matches.forEach(match => {const newLi =match {border: 1px solid ccc;padding: 10px;width: 150px;text-align: center;
}.team-name {font-weight: bold;
}.score {font-size: 1.5em;
}HTML 說明標(biāo)題:實(shí)時(shí)足球比分正文:一個(gè) `ul` 列表,用于顯示實(shí)時(shí)比分?jǐn)?shù)據(jù)。JavaScript 說明從 API 端點(diǎn) `` 獲取實(shí)時(shí)比分?jǐn)?shù)據(jù)。每隔 1000ms 更新一次比分?jǐn)?shù)據(jù)。CSS 說明設(shè)置頁(yè)面樣式,包括字體、文本對(duì)齊、列表樣式等。定義 `match` 元素的樣式,使其顯示為一個(gè)邊框框,并包含球隊(duì)名稱和比分。