// ES9 Promise 拓展 Promise.prototype.finally() // 成功失败都会执行
new Promise((resolve, reject) => {
setTimeout(() => {
// resolve(‘成功‘)
reject(‘fail‘)
}, 1000)
}).then(res => {
console.log(res)
}).catch(err => {
console.log(err)
}).finally(() => {
console.log(‘finally‘)
})
// 场景应用 使loading消失
// 数据库关闭操作
ES9 Promise 拓展 Promise.prototype.finally()
原文:https://www.cnblogs.com/hekeying/p/14589602.html