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