流星铁路由器无法从路由获取当前路径 [英] Meteor Iron Router does not get Current Path from Route

查看:55
本文介绍了流星铁路由器无法从路由获取当前路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在模板帮助器中,我从Iron.Router获取当前路径.(iron:router)如下:

In a Template Helper I get the current path from Iron.Router (iron:router) as follows:

Router.current().route.path(this);

这很好用,除非路由路径中确实包含参数 (e.g. /client/:_id/edit).在这种情况下,path()函数将返回null.

This works fine, unless the route path does contain parameters (e.g. /client/:_id/edit). In that case the path() function returns null.

当路由包含参数时,如何在模板帮助器中获取当前路径?

How do I get the current path within a Template Helper, when the route contains parameters?

围绕该问题有很多帖子,但是那里提到的解决方案似乎不合适.

There are posts around covering the issue but the solution mentioned there seem not to fit.

我正在将流星1.1.5与iron:router1.0.7一起使用

I'm using Meteor 1.1.5 with iron:router1.0.7

推荐答案

根据此 iron-router/issues/289 ,当路径包含参数时会出现问题.使用Iron.Location.get().path的建议对我来说很好.

According to this iron-router/issues/289 there are problems when the path contains parameters. The suggestion to use Iron.Location.get().path This works well for me.

这篇关于流星铁路由器无法从路由获取当前路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆