uni-Identify-quality/tm-vuetify/tool/function/sleep.js
2023-09-19 15:48:24 +08:00

17 lines
307 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 作者tmzdy
* 延时操作
* @param {Number} wait = [500] 延时
*/
function sleep(wait=500){
let timid = null;
if(wait==0) return Promise.resolve(true)
clearTimeout(timid);
return new Promise((res,rej)=>{
timid = setTimeout(function() {
res();
}, wait);
})
}
export default sleep;