这取决于你所说的“等待回调完成”的意思。它是同步运行(因此连续运行)的非常慢的函数吗?好的。d3.timer(() => { const now = Date.now(); while(Date.now() - now < 1000) {}; // do nothing, but keep the process engaged console.log("Ping");});<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>但如果它是一个异步函数——比如一个 API 调用——它会取消进程的调度,那么就不会。let i = 0, j = 0;d3.timer(() => { // Break after 100 iterations if(j > 100) { return true; } // do nothing, but release the process // so the thread can go do other things console.log("Scheduled promise", j); j++; return new Promise((resolve) => { setTimeout(() => { resolve(i); console.log("Resolved promise", i); i++; }, 1000); });});<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>