Vue的報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#'

https://blog.csdn.net/u013809856/article/details/80312774(copy)

Vue的報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

 

 剛剛運行一下以前的一個Vue+webpack的demo,運行之后沒有出現想象中的效果,並且報錯

Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

 

點開錯誤的文件,標注錯誤的地方是這樣的一段代碼:

  1.  
    import {normalTime} from './timeFormat';
  2.  
     
  3.  
    module.exports={
  4.  
      normalTime
  5.  
    };

就是module.exports;

 

百度查不到,google一查果然有。

原因是:The code above is ok. You can mix require and export. You can‘t mix import and module.exports.

翻譯過來就是說,代碼沒毛病,在webpack打包的時候,可以在js文件中混用require和export。但是不能混用import 以及module.exports。

因為webpack 2中不允許混用import和module.exports,

解決辦法就是統一改成ES6的方式編寫即可.

 

  1.  
    import {normalTime} from './timeFormat';
  2.  
     
  3.  
    export default normalTime;

最后運行成功。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 vue 項目啟動報錯:Cannot assign to read only property 'exports' of object '#' 解決 Cannot assign to read only property 'exports' of object '#' 問題 Cannot assign to read only property 'exports' of object 解決辦法 sdk uncaught third Error Cannot assign to read only property 'constructor' of object '# ' (小程序) vue報錯 Uncaught TypeError: Cannot read property ‘children ’ of null vue項目中引入 html2canvas ,控制台報錯 Cannot assign to read only property 'className' of object '#< SVGSVGElement >' 前台報錯:Uncaught TypeError: Cannot read property '0' of null js 報錯 Uncaught TypeError: Cannot read property 'trim' of undefined vue報錯getVueAllUser:67 Uncaught TypeError: Cannot read property 'userId' of undefined VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM