简体   繁体   English

Meteor.js模板回显不起作用

[英]Meteor.js template echo not working

I'm following a Meteor tutorial, following it step by step and I have run into two issues: 我正在跟踪流星教程,并逐步学习,遇到了两个问题:

1) when I call the {{> message}} between {{#each messages}} and {{/each}}, my "check if it works" doesn't show up at all. 1)当我在{{#each messages}}和{{/ each}}之间调用{{> message}}时,我的“检查是否有效”根本没有出现。 When I call the {{> message}} anywhere else, my "check if it works" shows up! 当我在其他任何地方致电{{> message}}时,将显示“检查是否有效”! {{messages}} {{消息}}

<template name="messages">
<h3>message list</h3>
{{#each messages}}
    {{> message}} <!--echo of message template-->
{{/each}}
</template>

<template name="message">
<h4>check if it works</h4> <!--didn't show up on page-->
<p>{{name}}: {{message}}</p> 
</template>

2) Also none of my Javascript works at all. 2)同样,我的Javascript都没有用。 I type in 'Messages.insert({ name: 'Eunice', message: 'hello world', time: 10})' to the console. 我在控制台中输入“ Messages.insert({名称:'Eunice',消息:'hello world',时间:10})'。 and it is supposed to have Eunice: hello world pop up, sorted by time. 而且应该有Eunice:您好世界弹出,按时间排序。 Messages = new Meteor.Collection('messages'); 消息=新的Meteor.Collection('messages');

if (Meteor.is_client){
  Template.messages.messages = function () {
    return Messages.find({}, { sort: {time: -1} });
  };
}

I'm usually a good de-bugger, so I don't know where I made a mistake. 我通常是个不错的调试员,所以我不知道自己在哪里犯错。 So I probably misunderstood how something works going from console to collections to templates. 因此,我可能会误解了从控制台到集合再到模板的工作原理。 Thanks! 谢谢!

Your if check is incorrect 您的支票不正确

if(Meteor.is_client) {

}

Should be 应该

if(Meteor.isClient) {

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM