0
这是我尝试加载widget.tpl时简单的BackboneView。 但是模板var包含一个函数()骨干的handlebars和requirejs:handlebars返回一个函数,而不是html
我该怎么做错?
define(['hbs!templates/widget'],function (template) {
var template = Handlebars.compile(template);
console.log(template);
MyView = Backbone.View.extend({
initialize: function(){
this.render();
},
render: function(){
// Compile the template using Handlebars
console.log(template);
//this.el.html(template);
}
});
return MyView;
});
widget.tpl具有
<div>helloworld</div>
是不是标准的行为?尝试'console.log(template())'。 – Puigcerber
'Handlebars.compile'将带有占位符的模板转换为可以使用占位符参数执行的函数,以获取所需的HTML。 – Cyclone
我的回答有帮助,还是需要帮助? – bejonbee