其实就是用到了 递归,在函数内,继续调用函数本身
const interval = (cb, time) => {
setTimeout(() => {
cb()
interval(cb, time)
}, time)
}
interval(() => {
console.log('执行了');
}, 2000)