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
Layout 特定路由器的自定义布局未显示在Meteor with Iron router中_Layout_Meteor_Iron Router - Fatal编程技术网

Layout 特定路由器的自定义布局未显示在Meteor with Iron router中

Layout 特定路由器的自定义布局未显示在Meteor with Iron router中,layout,meteor,iron-router,Layout,Meteor,Iron Router,我想为登录、404和其他页面使用不同的布局模板。但是,在我的路由中调用此模板(使用Iron Router)时,它似乎被忽略,而是使用默认模板。我如何更新它,使其使用预期的布局 这是我要使用的自定义布局 <template name="UtilityLayout"> <div class="ui centered grid"> <div class="six wide column"> {{> yield}} </di

我想为登录、404和其他页面使用不同的布局模板。但是,在我的路由中调用此模板(使用Iron Router)时,它似乎被忽略,而是使用默认模板。我如何更新它,使其使用预期的布局

这是我要使用的自定义布局

<template name="UtilityLayout">
  <div class="ui centered grid">
    <div class="six wide column">
      {{> yield}}
    </div>  
  </div>
</template>
    Router.onBeforeAction(function () {

     //redirect to /login if a user is not signed and if they are not already on login (to prevent a redirect loop)
      if (!Meteor.userId() && (Router.current().route.getName() !== 'login')) {
        this.redirect('login');
        // I also tried Router.go('login');
      } else {
        this.next();
      }
    });
这是我呼叫路线的前弯钩

<template name="UtilityLayout">
  <div class="ui centered grid">
    <div class="six wide column">
      {{> yield}}
    </div>  
  </div>
</template>
    Router.onBeforeAction(function () {

     //redirect to /login if a user is not signed and if they are not already on login (to prevent a redirect loop)
      if (!Meteor.userId() && (Router.current().route.getName() !== 'login')) {
        this.redirect('login');
        // I also tried Router.go('login');
      } else {
        this.next();
      }
    });
这是我引用自定义布局的路线(似乎被忽略):

    Router.route('/login', { name: 'login'}, function(){
       this.layout('UtilityLayout');
    });

您可以定义一个
路由控制器
,我认为它应该覆盖全局
路由器。配置
参数。这很有效,谢谢!您可以定义一个
路由控制器
,我认为它应该覆盖全局
路由器。配置
参数。这很有效,谢谢!您可以定义一个
路由控制器
,我认为它应该覆盖全局
路由器。配置
参数。这很有效,谢谢!