console.log('main-1')
function foo(param){
var p=new Promise(function(resolve,reject){
console.log('promise-1');
if(parem==1){
resolve('1')
}else{
reject('2')
}
console.log('promise-2')
})
return p;
}
console.log('main-2');
foo(1).then(function(value){
console.log('then-1');
})
console.log('main-3')
运行结果是 main-1
main-2
promise-1
promise-2
main-3
then-1
为什么main-3 会在promise运行之后
郎朗坤
相关分类