Layout 特定路由器的自定义布局未显示在Meteor with Iron router中
我想为登录、404和其他页面使用不同的布局模板。但是,在我的路由中调用此模板(使用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
<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');
});
您可以定义一个
路由控制器
,我认为它应该覆盖全局路由器。配置
参数。这很有效,谢谢!您可以定义一个路由控制器
,我认为它应该覆盖全局路由器。配置
参数。这很有效,谢谢!您可以定义一个路由控制器
,我认为它应该覆盖全局路由器。配置
参数。这很有效,谢谢!