How to get the query parameters in Iron-router?

前端 未结 8 1338
不知归路
不知归路 2020-12-13 10:24

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 mis

8条回答
  •  执笔经年
    2020-12-13 11:03

    Interestingly three answers and no one offered the complete answer.

    Iron-Router 1.0.x

    From within a route, use:

    // URL: http://example.com/page/?myquerykey=true
    this.params.query   // returns the full query object
    this.params.query.myquerykey   // returns a particular query value
    

    Similarly, outside of the route (but still inside the client code), and inside your template, use:

    // URL: http://example.com/page/?myquerykey=true
    Router.current().params.query
    Router.current().params.query.myquerykey
    

    Query parameters, not to be confused with parameters passed via the URL.

提交回复
热议问题