如果我这样做 - 一切都很好 -
var UserList = Backbone.View.extend({
el: '.page',
render: function(){
var users = new Users();
users.fetch({
success: function() {
console.log('success');
}
})
this.$el.html('test');
}
});
但是当我将 插入this.$el.html('test');
到成功回调中时,我收到了一个错误:
TypeError:“未定义”不是对象(评估“this.$el.html”)
var UserList = Backbone.View.extend({
el: '.page',
render: function(){
var users = new Users();
users.fetch({
success: function() {
console.log('success');
this.$el.html('test');
}
})
}
});
控制台日志正确触发。