let promise = new Promise(resolve => {
setTimeout(() => {
console.log('promise 1')
resolve('hello');
}, 1000);
})
setTimeout(() => {
promise.then(v => {
console.log(v)
})
}, 3000);
执行结果
promise 1
hello
let promise = new Promise(resolve => {
setTimeout(() => {
console.log('promise 1')
resolve('hello');
}, 1000);
})
setTimeout(() => {
promise.then(v => {
console.log(v)
})
}, 3000);
执行结果
promise 1
hello