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,
},
],
],
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM