0
中的第三方模塊構造函數屬性變爲只讀使用JPM實用程序嘗試構建Firefox的加載項。如果我把在index.js以下,「棒」是呼應出到瀏覽器控制檯沒有任何問題JPM
'use strict';
function Foo() {
this.$data = false;
}
Foo.prototype.change = function(data) {
this.$data = data;
};
var Test = new Foo();
Test.change('bar');
console.log(Test.$data);
但是,如果我把一個文件中的以下稱爲test.js
'use strict';
function Foo() {
this.$data = false;
}
Foo.prototype.change = function(data) {
this.$data = data;
};
module.exports = new Foo;
並要求從index.js
var Foo = require('js/test');
Foo.change('bar');
我得到一個TypeError抱怨$數據是隻讀的。我如何需要使用構造函數屬性的第三方模塊?
這將在這個簡單的例子,但在我的實際使用情況我使用這種模式從多個文件需要的模塊的工作,然後被index.js需要 – ionclash 2015-04-03 16:57:11