如何使用 Meteor 和 Iron Router 通过模板中的路由名称检查路由 [英] How to check for Route through route name in template with Meteor and Iron Router
本文介绍了如何使用 Meteor 和 Iron Router 通过模板中的路由名称检查路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在模板中使用什么来确定与我当前所在的路线相关联的路线名称
?
What can I use in a template to figure out the route name
that is associated with the route that I am currently on?
例如,如果我在 iron-router
this.route('quick', {
path: '/wow/:_id',
template: 'create_question'
});
因此,如果我在路线 /wow/123
上,如何在模板中获取路由器的名称,在这种情况下如何在模板中获取 quick
?
So if I am on the route /wow/123
how can I get the router's name in my template, in this case how can I get quick
in my template?
我只是在寻找一个功能,我确信我可以使用把手助手来完成其余的工作.我只需要一个函数来调用.
I'm simply looking for a function, I am sure I can use a handlebars helper to get the rest done. I just need a function to call.
推荐答案
iron-router > 1.0
var routeName = Router.current().route.getName();
铁路由器<1.0
var routeName = Router.current().route.name;
这篇关于如何使用 Meteor 和 Iron Router 通过模板中的路由名称检查路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文