使用vue时,报错“exports is not defined”


在开发中引用插件时,报错“exports is not defined”

但在引用第三方组件的时候,在浏览器中报错“exports is not defined”。
根据浏览器报错信息,查询到报错来源是第三方组件的一段代码:

经过查资料,这是使用了CommonJs写法,而在应用中并没有做相应的模块转换使得浏览器能够识别。而导致这个问题是因为balbel的配置文件.babelrc的问题:

需要改动.babelrc文件即可:

其中{ "modules": false }阻止了babel进行模块转换,所以,将modules改为默认设置即可,或者删除该配置。

然后再次npm run dev即可。


免责声明!

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



猜您在找 Vue Cli 3 报错:router is not defined Vue 使用自定义组件时报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' python使用input()来接受字符串时一直报错“xxx is not defined” vue打包多页报错webpackJsonp is not defined vue-cli3 打包时使用‘babel-loader’遇到Cannot assign to read only property ‘exports’ of object '#'问题的解决方法。 Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#‘的解决方法 vue运行报错error:Cannot assign to read only property 'exports' of object '#' Vue报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object 的解决方法 Vue is not defined template or render function not defined vue 突然报错了,怎么解决
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM