Vue CLI3 爬坑指南,使用 elementUI 在 IE 下的兼容性问题,重复声明 h 问题,ES5 commonjs 模块问题等。持续更新中。
Troubleshooting
- exports is not defined
Uncaught ReferenceError: exports is not defined
如果该依赖交付 ES5 代码,但使用了 ES6+ 特性且没有显式地列出需要的 polyfill (例如 Vuetify):请使用 useBuiltIns: 'entry' 然后在入口文件添加 import '@babel/polyfill'。这会根据 browserslist 目标导入所有 polyfill,这样你就不用再担心依赖的 polyfill 问题了,但是因为包含了一些没有用到的 polyfill 所以最终的包大小可能会增加。more info
see vue-loader
- Duplicate declaration "h" (This is an error on an internal node. Probably an internal error.)
@vue/cli V3,不用配置可以直接用,否则配置后会报重复声明错误
但是 @vue/cli V2+,需要在 babel.config.js
显式配置:
module.exports = {
plugins: ["transform-vue-jsx"]
}
see babel-plugin-transform-vue-jsx
- element-ui 造成的 IE Compatability
如果 element-ui
版本是 2.4.9
可以直接使用。
2.4.9
未知。
如果 element-ui
版本是 2.4.11
在 IE浏览器中报错,需要在 vue.config.js
中加入,感觉原因是因为 eleFE 没有测试过 IE11 就发版了,这个问题找了我几个小时。解决办法是:
module.exports = {
transpileDependencies: ['element-ui']
}
see why need this