vue报错: Cannot assign to read only property 'exports' of object '#<Object>'
2017-09-15 14:35
471 查看
刚刚运行一下以前的一个Vue+webpack的demo,运行之后没有出现想象中的效果,并且报错Uncaught TypeError: Cannot assign to read only property ‘exports‘ of object ‘#<Object>‘ 点开错误的文件,标注错误的地方是这样的一段代码:
import {normalTime} from ‘./timeFormat‘; module.exports={
normalTime
};就是module.exports; 百度查不到,google一查果然有。原因是:The code above is ok. You can mix
requireand
export. You can‘t mix
importand
module.exports.翻译过来就是说,代码没毛病,在webpack打包的时候,可以在js文件中混用require和export。但是不能混用import 以及module.exports。因为webpack 2中不允许混用import和module.exports,解决办法就是统一改成ES6的方式编写即可.
import {normalTime} from ‘./timeFormat‘; export default normalTime;最后运行成功。
相关文章推荐
- Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#<Object>‘的解决方法
- vue引入插件Cannot assign to read only property 'exports' of object '#<Object>'
- vue引入插件Cannot assign to read only property 'exports' of object '#<Object>'
- Cannot assign to read only property 'exports' of object '#<Object>' 解决方案
- Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
- Cannot assign to read only property 'exports' of object '#<Object>' (mix require and export) #4039
- ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.
- Cannot assign value of type 'java.lang.String' to property 'file' of type 'org.apache.struts.upload.FormFile'
- Type mismatch: cannot convert from Enumeration<String> to Enumeration<Object>
- Type mismatch: cannot convert from Enumeration<String> to Enumeration<Object>
- “Cannot set the value of read-only property 'outputFile' for 。。。”解决
- struts2的<s:iterator>标签 遇到的问题:java.lang.ClassCastException:cannot be cast to java.lang.String
- Cannot set the value of read-only property 'outputFile'
- 关于Uncaught TypeError: Cannot read property 'toLowerCase' of undefined的问题
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Windows 8在Vmware 8 中安装提示:windows cannot read the<product key> setting from the unattend answer
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value ‘<Student: 0x8399f70>’