我想在我的vue应用程序中使用async/await语法。执行此操作时,我收到此错误:未定义ReferenceError: regeneratorRuntime
我已经在github上找到了多个解决方案,指向用户adi518的这个方向:https://github.com/adi518/vue-facebook-login-component/issues/17
就语法而言,我可能会在我的main.js的顶部尝试这样做,因为就职责而言,这是您通常初始化库和polyfills (App.vue似乎不相关)的地方。
So,
npm install --save regenerator-runtime
And then:
import "regenerator-runtime";我成功地运行了npm安装。另外,我的main.js现在将这个添加到了导入中: import‘regenerator- now’;
我可以构建项目,但运行时regeneratorRuntime仍然不起作用,我得到的是相同的referenceError。我还能做什么,或者我错过了什么?
发布于 2020-10-18 23:45:28
我通过安装core-js和regenerator-runtime解决了我的问题
npm i -S core-js@latest regenerator-runtime@latest然后在主文件的开头导入它,在我的例子中是main.js,因为它是在Webpack的entry密钥上声明的。
// Recomendation of babeljs (https://babeljs.io/docs/en/babel-polyfill)
import 'core-js/stable'; // only stable feature also is possible with only `core-js`
import 'regenerator-runtime/runtime'; // To ensure that regeneratorRuntime is defined globally我希望这将是有用的。致以问候。
https://stackoverflow.com/questions/60619067
复制相似问题