<script>
test()
test()
test() function test(){
setTimeout(function () { console.log('test')
},2000)
}`请输入代码`</script>2000毫秒秒后同时打印,怎么才能每隔2000毫秒打印一次
1 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
run()function test(sleep, callback) { return new Promise(resolve => setTimeout(() => { callback(); resolve(); }, sleep)) }async function run() { await test(2000, () => console.log('test')) await test(2000, () => console.log('test')) await test(2000, () => console.log('test')) }
添加回答
举报
0/150
提交
取消