meteor - Iron router : Error: Couldn't find a template named "/" or "". 你确定是你定义的吗?

标签 meteor iron-router

我在设置一个简单的 iron:router 示例时遇到了问题:( docs , sample app )

meteor create testapp
cd testapp

home.html:

<template name="Home">
  <h1>Welcome</h1>
  home
</template>

router.js:

Router.route('/', function () {
  this.render('Home'); // Also tried 'home'
});

启动服务器:

meteor

然后我得到(客户端):

Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it?
    at null._render (http://localhost:3000/packages/iron_dynamic-template.js?32038885cb1dad7957291ffebfffcb7f8cd57d20:239:17)
    at doRender (http://localhost:3000/packages/blaze.js?88aac5d3c26b7576ac55bb3afc5324f465757709:1853:25)
    ...

我做错了什么?

注意:如果我克隆 the example application,我会得到完全相同的错误(basic.html 和 basic.js)。

meteor list
autopublish      1.0.1  Publish the entire database to all clients
insecure         1.0.1  Allow all database writes by default
iron:router      0.9.4  Routing specifically designed for Meteor
meteor-platform  1.1.2  Include a standard set of Meteor packages in your app

还有:

meteor --version
Meteor 0.9.4 <- Why all standard packages and meteor platform are > 1.0 and this is 0.9.4 ?

最佳答案

目前iron:router有两个版本.

  • iron:router@0.9.4是输入meteor add iron:router时默认添加的那个,这个版本是iron:router的“遗留”分支中的最新版本一年多前出现的,每个人可能仍在使用,尽管他们肯定应该更新到...
  • iron:router@1.0.0-preXX = 4截至 2014 年 10 月 20 日,这是对包的完全重写,旨在向后兼容,但引入了一个新的、更好的和完善的 API。当 meteor 在今年晚些时候发布 1.0.0 时,这个版本可能会被设置为默认版本。问题是 iron:router 的 github 页面显示此特定分支 ( 1.0.0-pre4 ) 以及人们认为可与 0.9.4 一起使用的示例.

这意味着您很可能使用了错误版本的 iron router,使用 meteor remove iron:router 删除它和 meteor add iron:router@1.0.0-pre4相反。

推荐阅读了解最新iron:router语法:

http://eventedmind.github.io/iron-router/

有时该指南并不完全与预发布版本保持同步,如果您想了解最新信息,请查看 github issues。

关于meteor - Iron router : Error: Couldn't find a template named "/" or "". 你确定是你定义的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26450293/

相关文章:

meteor - 某些 Meteor 数据源能存活多久?

google-chrome - 你怎么去iron-router中的上一条路线?

Meteor 0.8.0、Iron Router 和 Discover Meteor

meteor - 使用 Iron Router 路由到 Meteor autoform 提交的新数据?

meteor - 使用 Meteor 和 Iron Router 创建事件导航状态

node.js - 如何设置环境变量以永远运行 meteorjs

javascript - meteor MDG :validated-method without using simple schema