Javascript 使用不同的参数使iron router进入同一页面
Iron router阻止我的模板呈现新页面,因为它似乎认为它已经存在 我正在处理的路线如下:Javascript 使用不同的参数使iron router进入同一页面,javascript,meteor,iron-router,Javascript,Meteor,Iron Router,Iron router阻止我的模板呈现新页面,因为它似乎认为它已经存在 我正在处理的路线如下: Router.route('/', { name: 'landingpage', template: 'landingpage', onBeforeAction: function() { this.next(); } }); Router.route('/chapter/:pathSlug/:chapterSlug', { name: 'chaptershow',
Router.route('/', {
name: 'landingpage',
template: 'landingpage',
onBeforeAction: function() {
this.next();
}
});
Router.route('/chapter/:pathSlug/:chapterSlug', {
name: 'chaptershow',
template: 'chaptershow',
//waitOn: function() {
//return [Meteor.subscribe('users'),
//Meteor.subscribe('ChapterCollection')];
//},
onBeforeAction: function() {
Session.set('currentRoute', 'chapter');
this.next();
}
});
假设我想展示两个章节:
/chapter/voyage/somestories
/chapter/voyage/someotherstories
从控制台,我可以轻松地从登陆页面转到任何一个航行页面,或者使用
Router.go('landingpage');
Router.go('/chapter/voyage/somestories');
但是,如果我在/chapter/seaveage/somestories
上,并尝试使用以下任一选项转到/chapter/seaveage/someotherstories
Router.go('/chapter/voyage/someotherstories');
Router.go('chaptershow', {pathSlug: 'voyage', chapterSlug: 'someotherstories'});
位置栏中的URL将更改为/chapter/voyage/someotherstories
,但不会加载新上下文
如何呈现我的新章节?以及当您的订阅未被注释掉时该怎么办?这不是一个真正的解决方案,但您可以尝试滥用包含部件的会话变量或用于确定视图内容的文档ID(
\u ID
)。会话变量也是被动的,我认为您可以更容易地控制它们(它们往往不会自动更改,而且显式的set和get是可用的)。请尝试在路由中包含数据:
定义。这应该加载与slug对应的任何文档。