使用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-2026 CODEPRJ.COM