使用MarionetteJS,由于某种原因,没有调用modelEvents():
export class MyView extends Marionette.ItemView<MyModel> {
constructor(public model: MyModel) {
super();
}
public events(): Backbone.EventsHash {
// This gets called by the framework
const events: Backbone.EventsHash = {};
return events;
}
public modelEvents() {
// This does not
return {};
}
}
我正在使用TypeScript,并使用依赖注入框架(aurelia-dependency-injection)将模型传递给构造函数。
答案 0 :(得分:0)
您忘记将模型传递给超级构造函数,因此您的模型正在丢失。尝试:
constructor(public model: MyModel) {
super(model);
}