使用 ES7 的 async/await 时报错—Uncaught ReferenceError: regeneratorRuntime is not defined

现象:
使用 ES7 的 async/await 时报错, 原因是缺少ES7的babel转译

解决方法:
1. npm install babel-plugin-transform-runtime --save-dev 

2. 在 .babelrc 文件中添加:
"plugins": [[
    "transform-runtime",
    {
      "helpers": false,
      "polyfill": false,
      "regenerator": true,
      "moduleName": "babel-runtime"
    }
  ]]

猜你喜欢

转载自www.cnblogs.com/tian-long/p/9141750.html