铁路由器:错误:找不到名为"/"的模板.或“".确定要定义吗? [英] Iron router: Error: Couldn't find a template named "/" or "". Are you sure you defined it?

查看:52
本文介绍了铁路由器:错误:找不到名为"/"的模板.或“".确定要定义吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设置一个简单的iron:router示例时遇到麻烦:(文档示例应用)

I have trouble setting up a simple iron:router example: (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

然后我得到了(客户端):

Then I get (client side):

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)
    ...

我在做什么错?

注意:如果我克隆示例应用程序,则会得到完全相同的错误(basic.html和basic.js).

Note: I get the exact same error if I clone the example application (basic.html and 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的旧版"分支中的最新版本,该版本已发布一年多了,它可能是每个人都可能使用的版本仍在使用,尽管它们肯定应该更新为...
  • 截至2014年10月20日,带有X = 4
  • iron:router@1.0.0-preXX = 4,是对软件包的完整重写,旨在向后兼容,但引入了一个新的,更好的和更优美的API.当今年晚些时候流星达到1.0.0时,可能会将此版本设置为默认版本.问题在于iron:router的github页面显示了此特定分支(1.0.0-pre4)以及人们认为可用于0.9.4的示例.
  • iron:router@0.9.4 is the one added by default when you type meteor add iron:router, this version is the latest in the "legacy" branch of iron:router that came up more than one year ago, it's the one that everyone is probably still using, although they should definitely update to...
  • iron:router@1.0.0-preX with X = 4 as of 20/10/2014, which is a complete rewrite of the package intended to be backward compatible, but introducing a new, nicer and polished API. This version will likely be set as default when meteor hits 1.0.0 later this year. The problem is that github page of iron:router shows this particular branch (1.0.0-pre4) along with examples that people believe are usable with 0.9.4.

这意味着您很可能使用了错误版本的Iron路由器,请改为使用meteor remove iron:routermeteor add iron:router@1.0.0-pre4删除它.

This means that you are most likely using the wrong version of iron router, remove it with meteor remove iron:router and meteor add iron:router@1.0.0-pre4 instead.

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

Recommended reading to learn about the latest iron:router syntax :

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

有时,该指南不是最新版本,如果您想了解最新信息,请查看github问题.

Sometimes the guide is not completely up-to-date with the pre-release version, if you want to keep up with the latest stuff take a look at github issues.

这篇关于铁路由器:错误:找不到名为"/"的模板.或“".确定要定义吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆