【问题标题】:Very Basic Meteor Routing To Template非常基本的流星路由到模板
【发布时间】:2014-06-09 10:04:28
【问题描述】:

Meteor 0.8.0.1 - 我从文档中了解到的,这个最小的应用程序

<head>
  <title>Meteor Routing Test</title>
</head>

<body>
  {{> renderPage}}
</body>

<template name="hello">
  <h1>Hello World!</h1>
</template>

Meteor.Router.add({
  '/hi':'hello',
});

应该在localhost:3000/hi 上获取并渲染名为hello 的模板。相反,文本 hello 被渲染成一个空的 html(即没有加载流星标头)。

我错过了什么?

【问题讨论】:

    标签: templates meteor router


    【解决方案1】:

    添加 Iron-router (-:

    mrt add iron-router
    

    试试这个:

    Router.map(function() {
      this.route('hi', {
        path: '/hi',
        template: 'hello'
      });
    });
    

    然后改成

    <body>
      {{> yield}}
    </body>
    

    【讨论】:

    • 这是使用铁路由器。我知道原来的路由器已弃用,建议使用铁路由器。但是我想使用原始路由器。那么这是否意味着routermeteor 0.8 不兼容?无论如何,您建议的方式确实有效。谢谢。
    • 我试过用原装路由器……太糟糕了。 Iron-router - 非常非常酷且功能强大。
    猜你喜欢
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-30
    • 2016-02-01
    • 1970-01-01
    • 2014-10-30
    相关资源
    最近更新 更多