在流星0.9.3.1中使用iron:router时出错 [英] Error when using iron:router with Meteor 0.9.3.1

查看:34
本文介绍了在流星0.9.3.1中使用iron:router时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试验Meteor和iron:router.我从 https://github.com/EventedMind/iron-router.git.然后,我将其CD-ed到样本/基本中,并运行流星更新和流星.我的流星版本是0.9.3.1

I am experimenting with Meteor and iron:router. I git cloned the examples from https://github.com/EventedMind/iron-router.git. I then cd-ed into samples/basic, and ran meteor update and meteor. My meteor version is 0.9.3.1

当我导航到网站时,控制台中显示错误,并且页面为空.错误如下:

When I navigated to the website an error is displayed in console and the page is empty. The error is as below:

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

有人可以建议我做错了什么吗?

Can someone kindly advise what I am doing incorrectly?

谢谢.

推荐答案

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

The reason you have this issue is there is a discrepancy between the iron-router@1.0.0-pre-x (like a Beta for 1.0) and the currently in use 0.9.x version of iron router.

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

The old notation for defining a route for http://localhost:3000/route, for the template route would be as follows:

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

但是在新版本中,当前在github上的devel上(我认为示例基于以下内容):

However in the new version, which is currently on github on devel (which I presume the examples are based on is as follows):

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

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

The problem is using the notation on the bottom would lead to the error Couldn't find a template named "/" since the first param of the Route.route is now a path instead of a template.

解决此问题的方法是使用铁路由器的预发行版本(版本字符串可在github上的package.js文件中找到):

The way to fix this is to either use the pre-release version of iron router (the version string can be found in the package.js file on github):

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

或者通过查看与github上的发行版捆绑在一起的示例而不是像这样的devel分支来使用旧的表示法:

Or to use the old notation by looking at an example bundled with a release on github instead of the devel branch like this one: https://github.com/EventedMind/iron-router/tree/v0.9.2-rc0

这篇关于在流星0.9.3.1中使用iron:router时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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