我是handlebars.js的新手,我开始尝试使用它。但是我已经被卡住了,你能解释一下我做错了什么吗?
这是在head标签中:
<script id="header" type="text/x-handlebars-template">
<div> {{ headerTitle }} </div>
Today is {{weekDay}}
</script>在身体里是这样的:
<script>
var theData = {headerTitle:"Shop Page", weekDay:"Wednesday"};
var theTemplateScript = $("#header").html();
var theTemplate = Handlebars.compile (theTemplateScript);
$(document).append (theTemplate (theData));
</script>该页面应返回以下内容:
商店页面今天是星期三
发布于 2013-06-11 17:51:14
模板可以工作,您只需要将生成的标记附加到一个元素。
$("body").append(theTemplate(theData));https://stackoverflow.com/questions/17040829
复制相似问题