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