使用熨斗时出错:Meteor 0.9.3.1路由器



我正在试验Meteor和iron:路由器。我从中克隆了这些例子https://github.com/EventedMind/iron-router.git.然后我cd到samples/basic中,运行流星更新和流星。我的流星版本是0.9.3.1

当我导航到网站时,控制台中会显示一个错误,页面为空。错误如下:

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?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1853:25)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1795:16
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:2029:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1794:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:476:11)
at Blaze.View.autorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1793:19)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1847:10 debug.js:41

有人能告诉我什么地方做得不对吗?

提前谢谢。

出现此问题的原因是iron-router@1.0.0-pre-x(如1.0的Beta)和当前使用的0.9.x版本的iron路由器之间存在差异。

为模板route定义http://localhost:3000/route路由的旧表示法如下:

Router.route("route", { path : '/' });

然而,在目前位于github on devel上的新版本中(我认为示例基于以下内容):

Router.route("/", function() {
    this.render("route");
});

问题是使用底部的符号会导致错误Couldn't find a template named "/",因为Route.route的第一个参数现在是路径而不是模板。

解决这个问题的方法是使用iron router的预发布版本(版本字符串可以在github上的package.js文件中找到):

meteor remove iron:router
meteor add iron:router@1.0.0-pre3

或者,通过查看github上与发行版捆绑在一起的示例,而不是像下面这样的devel分支,来使用旧的表示法:https://github.com/EventedMind/iron-router/tree/v0.9.2-rc0

最新更新