本文介绍了下划线_,模板无法识别的模板变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm使用下划线由require.js与text.js加载带有HTML模板,比如code波纹管:
I´m using underscore to load a html template with by require.js with text.js, like code bellow:
template: _.template(listItemTemplate)
, render: function () {
$(this.el).html(this.template(this.model.toJSON));
return this;
}
tvListItemTemplate.html 的
tvListItemTemplate.html
<h4><%= _id%></h4>
如果我做的console.log(this.model.toJSON()),它打印以下内容:
If i do console.log(this.model.toJSON()) it prints the following:
但控制台给我这个错误:
But the console give me this error:
我不明白,为什么
推荐答案
对不起,这一点,但它是在一个自己犯了愚蠢的错误:
Sorry for that but it was a own stupid error in:
$(this.el)的.html(this.template(this.model.toJSON ()));
$(this.el).html(this.template(this.model.toJSON()));
这篇关于下划线_,模板无法识别的模板变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!