如何在 Meteor Iron-Router 的其中一条路由中不显示默认模板?

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

我正在尝试在没有默认 layoutTemplate 的情况下呈现我的 home 模板。 Iron-router Guide显示我需要使用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'});