如何解决为什么关键字“this”会在一个函数中被识别,而在同一个 Backbone 视图中却不能被识别?
我收到此错误:
Uncaught TypeError: Cannot read property 'trigger' of undefined
在我的主干视图中。它说我的 this
函数中的 updateModel
未定义。
但我不明白为什么,因为我在整个视图的其余部分都使用了 this
,没有任何问题。他们都被认可了。
这是有问题的代码块。如您所见,我在其他地方成功使用了 this
。
为什么它在我的 updateModel
函数中不起作用?
events() {
'click #moreData': 'renderMain',},render: function() {
// bunch of code related to styling and changing css
return this;
},renderMain(e) {
setTimeout(_.bind(this.loadData,this),1);
},loadData: function () {
this.renderComponent(microPlane,{
model: this.model,updateModel: this.updateModel },'.modelLayout');
},updateModel: function () {
this.trigger('change',this.model);
}
我就是想不通:/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。