babel-plugin-await-add-trycatch

cnpm i babel-plugin-await-add-trycatch -D
//babel.config.js
module.exports = {
  presets: ['@vue/cli-plugin-babel/preset'],
  plugins: [
    [
      require('babel-plugin-await-add-trycatch'),
      {
        exclude: [], // 默认值 []
        include: [], // 默认值 ["src"]
        printErrorInfo: false // 默认值 true
      }
    ]
  ]
}

// 示例
async function fn() {
   await new Promise((resolve, reject) => {
    reject('failure')
  })
}
fn()
image.png

你可能感兴趣的:(babel-plugin-await-add-trycatch)