<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script type="text/javascript"> function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function demo() { for(var i=0;i<10;i++){ await sleep(1000); //间隔多少毫秒 console.log(new Date()); //修改成要执行的代码 } } demo(); </script> </body> </html>