【发布时间】:2016-06-13 13:20:44
【问题描述】:
我正在尝试在 Meteor 中显示带有参数的 URL,如下所示:
http://localhost:3000/test/123
我的 routes.js 包含以下内容:
Router.route('/test/:x1', function () {
this.render('test', {
to:"main",
param:this.params.x1
});
});
和main.html下面的模板
<template name="test">
<h2>Test {{param}}</h2>
</template>
但是,当我访问 http://localhost:3000/test/123 时,我收到以下错误消息:
Oops, looks like there's no route on the client or the server for url:
"http://localhost:3000/test/123."
我已经从 Ironrouter 文档中逐字复制了这个内容。 Stackoverflow 的其他问题,例如 Meteor deploy Iron:Router "oops looks like there's no route on the client or the server for url" 似乎并没有完全解决这个问题
【问题讨论】:
-
我假设您使用的是 Meteor 1.3。您是否在客户端的 main.js 文件中添加了路由文件?
-
这很奇怪。我复制了你的代码,它可以工作。您将
routes.js文件放在哪个目录中? -
Faysal:不,只是将 routes.js 添加到客户端目录。是否应该使用 import './routes.js' 在 main.js 中导入;陈述?我试过了,但并没有改变。
-
Tdm:Routes.js 在客户端目录中。它是 Meteor 1.3.2.4
标签: meteor iron-router