我是新手柄,并且被困在通过手柄脚本呈现模板中。以下是代码。输出不包含传递给模板的对象属性。请帮忙!手把模板无法读取通过的数据
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.4/handlebars.js"> </script>
<script>
var context = { "name" : "XYZ", "occupation" : "developer" };
var templateScript = $('#handlebars-demo').html();
var theTemplate = Handlebars.compile(templateScript);
var html = theTemplate({name: "XYZ",occupation: "developer"});
console.log(html);
$(document.body).append(html);
</script>
<script id="handlebars-demo" type="text/x-handlebars-template">
<div>
My name is {{name}}. I am a {{occupation}}. // This just just renders My name is . I am a .
</div>
按预期工作http://codepen.io/anon/pen/Wxyxdz – eltonkamami
它门槛不工作在我的应用程序有..它必须在我的节点应用程序中使用把手的方式做任何事情? – Vatsan28
同样在这里。 https://jsfiddle.net/3hjLztom/浏览器控制台中的任何错误? – ronnyfm