我试图将这个jQuery模板转换为一个underscorejs模板,但没有意义为什么它不工作。谁能解释为什么?从旧的转换下划线模板的错误
el: $('#contents'),
template: _.template(MenuTemplate),
//template: $('#item-tmpl').template(),
render: function()
{
this.$el.empty();
//$.tmpl(this.template, this.model.toArray()).appendTo(this.el);
// Old jquery template
//this.$el.html(this.template(this.model.toArray()).appendTo(this.el));
//underscore template
return this;
}
什么不工作?我不明白你使用模板并设置到根元素的技巧(不需要调用appendTo)。请参阅[这里](http://backbonejs.org/#View-render)。 – WiredPrairie 2013-03-15 10:49:25