vue-cli 3.0不能用module.exports为undefined,导致第三方js都没有办法引用

新的 vue-cli 默认禁止了 commonjs 语法
可以添加 babel 插件解决

yarn add @babel/plugin-transform-modules-commonjs -D

npm install --save-dev @babel/plugin-transform-modules-commonjs

编辑 babel.config.js

module.exports = {
presets: ['@vue/app'],
plugins: [
[
'@babel/plugin-transform-modules-commonjs',
{
allowTopLevelThis: true,
},
],
],
}

posted @ 2019-10-15 09:20  文杰_豆豆  阅读(2712)  评论(0编辑  收藏  举报