我一直在我的主干应用程序中使用 this.$el
,如下所示:
render: function() {
this.$el.html(this.template);
},
然后我在网上看到代码使用:
render: function() {
var dict = this.model.toJSON();
var html = this.template(dict);
$(this.el).append(html);
}
两者有什么区别?
最佳答案
如果你调用 $(this.el),你只是继续执行 jquery selector得到相同的 jquery 对象。 '$el' 是 $(this.el) 的缓存版本
关于javascript - 主干 - this.$el vs $(this.el)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19013531/