如何在Meteor Iron路由器中的一条路由中不显示默认模板

How to not display the default template in one of the routes in Meteor Iron-Router?

本文关键字:路由 显示 默认 一条路 Meteor Iron 路由器 一条      更新时间:2023-09-26

我正在尝试在没有默认layoutTemplate的情况下呈现我的home模板。Iron路由器指南显示我需要使用Router.onBeforeAction。我只是不知道如何实现它。

Router.configure({
 layoutTemplate: 'navbar'
}
Router.route('/', {name: 'home'});

您可以通过在路由中调用this.layout();来覆盖默认布局模板。要么提供不同的布局模板,例如this.layout('homeLayout');,要么将参数留空。

例如:

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