主队 0 客队 0 <script> // 通过 WebSocket 连接到实时比分服务器const socket = new WebSocket('ws://example.com:8080');// 监听服务器发送的实时比分数据socket.onmessage = (event) => {const data = JSON.parse(event.data);// 更新比分数据const homeTeamScore = document.querySelector('.scoreboard-row:nth-child(1) .score');const awayTeamScore = document.querySelector('.scoreboard-row:nth-child(2) .score');homeTeamScore.textContent = data.homeTeamScore;awayTeamScore.textContent = data.awayTeamScore;// 在比分有变化时添加高亮效果if (data.highlight) {homeTeamScore.classList.add('highlight');awayTeamScore.classList.add('highlight');setTimeout(() => {homeTeamScore.classList.remove('highlight');awayTeamScore.classList.remove('highlight');}, 500);}}; </script>