Templates 如何在多个Ironrouter路由中使用一个模板?
我想用路径“/”和“/home”显示名为“home”的模板,但用我的代码它不起作用Templates 如何在多个Ironrouter路由中使用一个模板?,templates,meteor,iron-router,Templates,Meteor,Iron Router,我想用路径“/”和“/home”显示名为“home”的模板,但用我的代码它不起作用 /** Iron router config file **/ Router.configure({ layoutTemplate: 'layout', notFoundTemplate: '404', loadingTemplate: 'loading', fastRender: true, }); // Home Router.route('/', { name: 'home', w
/** Iron router config file **/
Router.configure({
layoutTemplate: 'layout',
notFoundTemplate: '404',
loadingTemplate: 'loading',
fastRender: true,
});
// Home
Router.route('/', {
name: 'home',
waitOn: function() {
return [
Meteor.subscribe('infosContainers'),
Meteor.subscribe('infosMachines'),
Meteor.subscribe('alertes'),
];
},
fastRender: true,
});
Router.route('/home', {
name: 'home',
waitOn: function() {
return [
Meteor.subscribe('infosContainers'),
Meteor.subscribe('infosMachines'),
Meteor.subscribe('alertes'),
];
},
fastRender: true,
});
它不喜欢模板“home”在两条路由中的事实(因为如果我在第二条路由中设置name:sokasok
,它会工作)
你能帮我吗?'name'不是用于模板渲染的,它是路由的名称。您需要做的是在路由的
action
中调用this.render('home')
Router.route('/home', {
waitOn: function() {
return [
Meteor.subscribe('infosContainers'),
Meteor.subscribe('infosMachines'),
Meteor.subscribe('alertes'),
];
},
action: function(){
this.render('home');
}
fastRender: true,
});