【发布时间】:2016-01-07 14:13:11
【问题描述】:
我想显示不同城市的帖子,由cityId定义:
FlowRouter.route("/:cityId", {
name: 'postList',
action: function() {
console.log(FlowRouter.getParam("cityId"));
return BlazeLayout.render('mainLayout', {
top: 'header',
body: 'postList'
});
}
});
除此之外,我当然还有通用路由,例如“管理员”、“注册”等。
但是当我转到/signup 时,postList 路由被激活,将“注册”字视为城市 ID,并且“注册”在控制台中登录。
不能像FlowRouter.route("/postList/:cityId") 这样定义路由。
【问题讨论】:
-
'定义像 FlowRouter.route("/postList/:cityId") 这样的路由不是一个选项。不幸的是,这是您唯一的选择。只需创建一个
/city/:cityId路由。 -
如果您在 / 之后创建所有变量,则路线“/:cityId”每次都会评估为真。我唯一的另一个想法是创建一个像“/pages/signup”这样的路由,看看第二个斜杠是否会导致它不将该路由评估为“/:cityId”路由。
-
@BrettMcLain,是的,该解决方案有效)
标签: meteor flow-router