axios优化无论是then或catch都会执行的代码(finally)/es7-es12新特性

Promise.prototype.finally()

new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve('success')
        // reject('fail')
    }, 1000)
}).then(res => {
    console.log(res)
}).catch(err => {
    console.log(err)
}).finally(() => {
    console.log('finally')
})

 

es7-es12新特性

https://mp.weixin.qq.com/s/niuQ-Ga3DXwriCnoenvpxA

posted @ 2022-03-31 17:39  LouisVuitt  阅读(820)  评论(0编辑  收藏  举报