Vue:需要一个包:不能分配给对象'#<object>'的只读属性'exports'

时间:2018-02-11 12:26:07

标签: javascript ecmascript-6 vue.js vuejs2 es6-modules

我在我的项目中安装了包resource-bundle,现在在main.js中使用它:

/*main.js*/
var co=require('co');
var loader = require('resource-bundle');
co(function*(){
   ...
   ...
}).catch(onerror);

这是在资源包软件包的index.js中:

 /*index.js*/
 module.exports = function*(locale, dir, baseName) {
    ...
    ...
    ...
 }

收到此错误:

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

有什么问题?

1 个答案:

答案 0 :(得分:-1)

为什么你的module.exports是一个函数?

它应该是Object Literal,如下所示:

module.exports = {
key:"value",
intro:"my name is %s,in class %d",
mk:"%s%s%s"

}