是什么导致“模板未定义”在流星? [英] What causes "Template is not defined" in Meteor?
问题描述
这个非常简单的Meteor应用程序在加载时抛出模板未定义
错误。该应用程序基本上与样板项目( meteor create
)相同,只是拆分为服务器/客户端/公共目录。
<在全局模板对象实际就绪之前,Meteor似乎试图渲染Handlebars
template
标签。当我可以进入JS控制台并输入模板时,它就在那里。 我做错了什么,或者这是一个时间错误?
嗯,这可能会解决你的问题:
注意body标签包含模板名称,但不包含模板:
< body>
{{>你好}}
< / body>
< template name =hello>
{{greet}}
< / template>
另外,请注意.greet是指{{greet}}:
if(Meteor.isClient){
Template.hello.greet = function(){
return嘿!;
};
}
所以,问题在于你身体里面没有模板。相反,正文使用{{> hello}}调用模板,如上面的代码所示。
This extremely simple Meteor app is throwing a Template is not defined
error on load. The app is essentially identical to the boilerplate project (meteor create
), just split into server/client/public directories.
Meteor seems to be trying to render the Handlebars template
tags before the global Template object is actually ready. By the time I can get to the JS console and type "Template", it is there.
Have I done something wrong, or is this a timing bug?
Hm, perhaps this will solve your issue:
Note that the body tag includes the template name but not the template:
<body>
{{> hello}}
</body>
<template name="hello">
{{greet}}
</template>
Also, note that ".greet" refers to {{greet}}:
if (Meteor.isClient) {
Template.hello.greet = function () {
return "Hey!";
};
}
So, the issue was that you can't have a template inside the body. Instead, the body calls the template with {{> hello}} as in the above code.
这篇关于是什么导致“模板未定义”在流星?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!