文章目录
1,创建promise
const promise = new Promise(function(resolve, reject){
setTimeout(function(){
resolve("ok");
},1000);
})
promise.then(function(msg){
console.log(msg);
})
2, then
两个参数。
第一个是resolve回调,第二个是reject回调。
promise.then(function(){}[, function(){}])
3,Promise.all()
4,Promise.allSettled()
5,Promise.any()
6,Promise.catch()
7,Promise.finally()
不论Promise
执行结果如何,都会执行finally
。