不需要任何安装框架,代码量少,只需要浏览器就可以。不用上网。
结果:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>clock</title>
<style>
#clock {
font: bold 24px sans-serif;
background: #ddf;
padding: 15px;
border: solid black 2px;
border-radius: 10px;
}
</style>
</head>
<body>
<h1>数字电子钟</h1>
<span id="clock"></span>
<script>
function displayTime() {
let clock = document.querySelector('#clock');
let now = new Date();
clock.textContent = now.toLocaleString();
}
displayTime();
setInterval(displayTime, 1000);
</script>
</body>
</html>