let a = true;
function throttle() {
return new Promise((resolve, reject) => {
if (a) {
a = false;
setTimeout(() => {
a = true;
}, 1000);
resolve("");
} else {
reject("");
}
});
}
const touch = async() => {
await throttle()
console.log('11111')
}
使用promise实现节流
最新推荐文章于 2024-05-25 14:02:07 发布