Javascript 如何使用Meteor和Iron路由器通过模板中的路由名称检查路由

Javascript 如何使用Meteor和Iron路由器通过模板中的路由名称检查路由,javascript,meteor,iron-router,Javascript,Meteor,Iron Router,我可以在模板中使用什么来确定与我当前所在的路线关联的路线名称 例如,如果我在iron router this.route('quick', { path: '/wow/:_id', template: 'create_question' }); 因此,如果我在路由/wow/123中,如何在模板中获取路由器的名称,在这种情况下,如何在模板中获取quick 我只是在寻找一个功能,我相信我可以使用车把助手来完成其余的工作。我只需要一个函数来调用。iron router>1.0 铁刨

我可以在模板中使用什么来确定与我当前所在的路线关联的
路线名称

例如,如果我在
iron router

this.route('quick', {
    path: '/wow/:_id',
    template: 'create_question'
});
因此,如果我在路由
/wow/123
中,如何在模板中获取路由器的名称,在这种情况下,如何在模板中获取
quick

我只是在寻找一个功能,我相信我可以使用车把助手来完成其余的工作。我只需要一个函数来调用。

iron router>1.0 铁刨<1.0
您可以尝试Router.current()。模板

对于较新的iron路由器,请使用:

var routeName = Router.current().route.getName()

这将输出您使用
This.route()定义的实际路线的名称。

您可以在路线配置中定义任何选项:

Router.route('/', {
    name : 'home',
    template : 'home',
    title: 'Home'
});
然后使用以下内容访问标题:

Router.current().route.options.title
这将输出“Home”

Router.route('/', {
    name : 'home',
    template : 'home',
    title: 'Home'
});
Router.current().route.options.title