setTimeout(() => {
console.log('setTimeout')
}, 0)
let promise = new Promise((resolve, reject) => {
console.log('1')
setTimeout(() =>{
console.log('timeStart')
resolve('success')
console.log('timeEnd')
}, 0)
console.log('2')
})
promise.then((res) => {
console.log(res)
})
// 1 2 setTimeout timeStart timeEnd success
// 注意: 最后这个 promise.then 微任务没有立即执行,而是等待宏任务执行完,把 promise resolve 之后才会执行
标签:resolve,console,log,setTimeout,promise,执行 From: https://www.cnblogs.com/zjy4fun/p/17523834.html