How to get query string in Polymer

2019-05-01 08:40发布

Is there anyway how can I get query string in Polymer?

http://localhost:8080/search?param=ppshein

I want to get search?param=ppshein or param=ppshein in Polymer.

I've tried to get query string in app-route but it display nothing.

<app-route
    route="[[route]]"
    pattern="/:id"
    data="{{routeData}}"></app-route>

[[routeData.id]] **

1条回答
干净又极端
2楼-- · 2019-05-01 09:18

You could use <app-location>.queryParams:

<app-location route="{{route}}" query-params="{{queryParams}}"></app-location>

queryParams is an object containing key/value pairs of the parsed query parameters. Given http://localhost:8080/search?param=ppshein, queryParams would be:

{
  param: 'ppshein'
}
查看更多
登录 后发表回答