首页 > 其他 > 详细

ES9 Promise 拓展 Promise.prototype.finally()

时间:2021-03-28 21:36:27      阅读:24      评论:0      收藏:0      [点我收藏+]

// 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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!