Iron-router 如何获取查询参数? [英] How to get the query parameters in Iron-router?

查看:11
本文介绍了Iron-router 如何获取查询参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 url 中的查询参数.

I am trying to get the query parameters in the url.

似乎没有一种简单的方法可以做到这一点...

There doesn't seem to be an easy way to do this...

这让我觉得我一定错过了文档中的某些内容.

which leaves me with the feeling that I must have missed a something in the doc.

推荐答案

iron router >= 1.0

路由的查询参数可用作this.params.query的属性.

如果您的网址如下所示:

If your URL looked like:

/posts/5?sort_by=created_at

然后 this.params.query.sort_by 将等于 'created_at'.

铁路由器<1.0

路由的查询参数可作为 this.params 的属性使用.

A route's query parameters are available as properties of this.params.

如果您的网址如下所示:

If your URL looked like:

/posts/5?sort_by=created_at

然后 this.params.sort_by 将等于 'created_at'.

这篇关于Iron-router 如何获取查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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