怎么中止一个async执行器的执行?
类似如下函数:
async asyncRun(run) {
const tasks = [...Array(100).keys()];
const executedCallback = () => {
// run after every task finished running
}
for (let i = 0; i < tasks.length; i += 1) {
await run(tasks[i], executedCallback);
}
}
1 回复
自己解决了: 在循环中加个条件触发return就可以了