【问题标题】:Vue: require a package :cannot assign to read only property 'exports' of object '#<Object>'Vue:需要一个包:不能分配给对象'#<Object>'的只读属性'exports'
【发布时间】:2018-07-21 17:40:39
【问题描述】:

我在我的项目中安装了包 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>'

有什么问题?

【问题讨论】:

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


    【解决方案1】:

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

    它应该是这样的Object Literal:

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

    }

    【讨论】:

    猜你喜欢
    • 2019-04-27
    • 2019-06-13
    • 2021-09-26
    • 1970-01-01
    • 2019-11-28
    • 2021-12-04
    • 2020-06-26
    • 2021-07-25
    • 1970-01-01
    相关资源
    最近更新 更多