创建Meteor.Router.add()后,Meteor显示[object Object]

时间:2014-04-16 15:42:51

标签: javascript meteor router

我正在关注this tutorial学习流星。添加第一个JS代码后,我在浏览器上获得[object Object]。我已经按照所解释的一切(除了我已经改变的一些名字,但我没有使用任何保留字),但我看不到任何其他内容。这部分是在前4分钟。这就是我的文件的外观:

demonstration.js:

CalEvents = new Meteor.Collection('calevents');
Session.setDefault('editing_calevent', null);
Session.setDefault('showEditEvent', false);
Meteor.Router.add({
    '/':'home',
    '/calendar':'calendar'  
})

calendar.html:

<template name="calendar">
    <div id="calendar">
        Hello world! Now at calendar.
    </div>
</template>

home.html的:

<template name="home">
    <div class="hero-unit">
        <p>Manage your calendar</p>
        <p><a class="btn btn-primary btn-large">Learn more</a></p>
    </div>  
</template>

demonstration.html:

<head>
  <title>Calendar app</title>
</head>

<body>
  {{>menu}}
    <div class="container-fluid">
        <div class="row-fluid"> 
            {{renderPage}}
        </div>
    </div>
</body>

我怀疑它与Meteor.Router.add()行有关,因为我在添加它之前做的很少。我已经尝试将页面更改为“/”显示到包含简单文本的其他页面,但它不起作用。

编辑添加:我正在通过Nitrous.io工作,我在添加路由器包之前安装了Meteorite。

提前致谢。

PS:我在这里和谷歌搜索过,但我找不到这个问题的任何答案。如果有的话,请将我指向正确的地址。

1 个答案:

答案 0 :(得分:5)

许多在0.8版之前使用Meteor的示例都不起作用,因此请务必查看最近更新的示例,例如Discover Meteor上的示例。

在这种情况下,router has been fixed to support Meteor 0.8和您的示例可以将{{renderPage}}替换为{{> renderPage}}。但是,示例的其余部分可能无法正常工作,正如其他人所提到的,路由器已被弃用Iron Router