我想在创建对象时调用函数。反正有吗?
return declare("myObject", mySuperObject, {
constructor: function (args) {
test();
lang.mixin(this, args);
},
test: function () {
console.log('test');
}
});
这导致ReferenceError: test is not defined
答案 0 :(得分:1)
改为使用this.test()
:
return declare("myObject", mySuperObject, {
constructor: function (args) {
this.test();
lang.mixin(this, args);
},
test: function () {
console.log('test');
}
});