Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 如何在多个Ironrouter路由中使用一个模板?_Templates_Meteor_Iron Router - Fatal编程技术网

Templates 如何在多个Ironrouter路由中使用一个模板?

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

我想用路径“/”和“/home”显示名为“home”的模板,但用我的代码它不起作用

/** 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,
});