{
"presets": ["es2015", "stage-2"],
"plugins": [
"transform-export-extensions",
["transform-runtime", {
"polyfill": true,
"regenerator": true
}]
],
"comments": false
}
通过 Sources, 确实也看到有加了 core-js/fn/promise,

代码中, 也能正常使用 new Promise, 但是用 IE9 访问时, Vuex 还是报vuex requires a Promise polyfill in this browser错误, 一定得手动引用import 'core-js/fn/promise', 才能正常使用.
transform-runtime 只影响你的应用代码,不作用于 Vuex 的代码,Vuex 自然拿不到 polyfill 的 Promise
明白了, 谢谢...
I'm not talking chineese... Can you explain me what is the solution please
@sotaan just install the babel-runtime http://babeljs.io/docs/plugins/transform-runtime/
So what's the solution here? Importing a whole 'babel-runtime' will break the advantages from runtime-plugin (only importing what you need).
@breeswish Using babel to load vuex would be the simplest approach.
With webpack it's something like:
{
test: /\.js$/,
loader: 'babel-loader',
include: [/vuex/]
}
@fnlctrl it didn't work for me?
@yyx990803
transform-runtime 只影响你的应用代码,不作用于 Vuex 的代码,Vuex 自然拿不到 polyfill 的 Promise
您好,尤大大,请问vue-cli中提示:
Vue CLI 使用了 Babel 7 中的新配置格式 babel.config.js。和 .babelrc 或 package.json 中的 babel 字段不同,这个配置文件不会使用基于文件位置的方案,而是会一致地运用到项目根目录以下的所有文件,包括 node_modules 内部的依赖。我们推荐在 Vue CLI 项目中始终使用 babel.config.js 取代其它格式。
这里面说了会包含node_modules,noParse我也改成了/^$/,transpileDependencies也是['node_modules'],为什么我babel.config.js配置了polyfill也没作用于vuex呢?谢谢
Most helpful comment
@breeswish Using
babelto loadvuexwould be the simplest approach.With webpack it's something like: