1
我在Requirejs中使用了Backbone.js和underscore.js。但是,當我嘗試加載我的視圖模板,它給我(8超出範圍6)錯誤在Underscore.js第8行。 請告訴我我做錯了什麼。(8超出範圍6)Underscore.js模板
這裏是我的代碼:
var imageView = new ImageView({model: item});
define(['jquery','underscore','backbone','imageview','text!../templates/template_image.html'],
function($, _, Backbone, ImageView, template){
var ImageView = Backbone.View.extend({
initialize: function(){
this.showImageTemplate = _.template(template);
},
render: function(){
var html = this.showImageTemplate(this.model);
this.$el.html(html);
return this;
}
});
return ImageView;
});
我的模板文件:
<img id="frameImg" src="<%= DocumentPath %>/<%= DocumentName %>" alt="image" title="image"/>
此外,當我嘗試CONSOLE.LOG(this.model)的渲染功能,它讓我看到我的完整的模型,但我得到的錯誤,當我運行我的代碼: 的ReferenceError:DocumentPath沒有定義(8超出範圍6) PS。 DocumentPath包含在型號 – xTMNTxRaphaelx