我一直在尝试传递一个模型对象以在我的模板中进行评估,但没有运气。我尝试了以下但没有运气
仪表板模型.js
var myMod = Backbone.Model.extend({
defaults: {
name: "mo",
age: "10"
}
});
myview.js
var dashView = Backbone.View.extend({
el: '.content-area',
this.mymodel = new myMod({}),
template: _.template(dashBoardTemplate, this.mymodel),
initialize: function() {
},
render: function() {
this.$el.html(this.template);
return this;
}
// more javascript code.............
仪表板.html
<p> Hello <%= name %> </p>
PS:我使用的是下划线模板引擎