This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 已setTimeout为例 | |
const wait = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
// 调用 | |
wait(1000).then(() => { | |
// do something | |
}); | |
// 这样回调起来就舒服多了 |