方法一
function sleep1(ms, cb){
setTimeout(cb, ms);
}
sleep1(3000, () => {
console.log(222);
});
方法二
function sleep2(ms){
return new Promise((resolve, reject) => {
setTimeout(resolve, ms);
});
}
sleep2(3000).then(() => {
console.log(222);
});
网友评论