简体   繁体   English

铁路由器的流星路由

[英]Meteor routing with iron router

I tried implementing iron:Router in the Meteor official TODO app tutorial. 我尝试在Meteor官方TODO应用程序教程中实现iron:Router。 I wanted to make the default "/" route point to the "home" template so I modified my todoapp.html page and encapsulated the whole code in a template tag like this: 我想将默认的“ /”路由指向“ home”模板,因此我修改了todoapp.html页面,并将整个代码封装在一个模板标签中,如下所示:

    <template name = "home">
    <head></head>
    <body>
    <ul>
          {{#each tasks}}
            {{> task}}
          {{/each}}
        </ul>
    </body>
    </template>
    <template name = "task">
<li>
 <span class="text"><a href="/user">{{username}}</a> - {{text}}</span>
  </li>
</template>

and in the todoapp.js I added this before isClient and isServer: 在todoapp.js中,我在isClient和isServer之前添加了它:

Router.route('/', {
    template: 'home'
});

Before adding the home template I got all the "task" objects. 在添加主模板之前,我获得了所有“任务”对象。 After encapsulating the code in a "home" template I don't get any of them. 将代码封装在“ home”模板中后,我什么也没得到。 I followed the official tutorial to implement the "todo" app. 我按照官方教程实施了“ todo”应用程序。

Can someone please help? 有人可以帮忙吗? Thanks in advance. 提前致谢。

head and body don't below in templates. headbody不在模板中。 Try this instead: 尝试以下方法:

<head></head>
<body>
</body>

<template name="home">
  Home
  <ul>
    {{#each tasks}}
      {{> task}}
    {{/each}}
  </ul>
</template>

<template name="task">
  Task
</template>

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

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