运行vue仿新闻客户端出错

 

运行一下以前的一个Vue+webpack的 vue仿新闻网站  小项目,报错

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

点开错误的文件,标注错误的地方是这样的一段代码:

这个是在/src/filters/index.js里的

1

2

3

4

5

import {normalTime} from './timeFormat';

 

module.exports={

  normalTime

};

就是module.exports;

解决方法

同过谷歌查找,和论坛各种搜索:

原因如下: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

2

3

import {normalTime} from './timeFormat';

 

export default normalTime;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值