1
我使用的聚合物-2和試圖從URL queryParams
後去除,但如果我打127.0.0.1:8081/listing?q=madrid然後將其重定向到127.0。 0.1:8081 /列表並正在從URL中刪除查詢參數。QueryParams正在重新加載頁面
其實我在主頁有一個搜索表單,填充完成後我想要去上市頁面,我用window.history.pushState
和window.dispatchEvent(new CustomEvent('location-changed'))
來傳遞參數。它的工作正常,但如果我重新加載頁面,然後所有queryParams
正在消失,只有path
存在。我app-location
和app-route
是
<app-location
route="{{route}}"
url-space-regex="^[[rootPath]]
query-params="{{queryParams}}"">
</app-location>
<app-route
route="{{route}}"
pattern="[[rootPath]]:page"
data="{{routeData}}"
tail="{{subroute}}">
</app-route>
<app-route
route="{{subroute}}"
pattern="/:view"
data="{{locationRoute}}">
</app-route>
我的鐵頁面元素
<iron-pages
selected="[[page]]"
attr-for-selected="name"
fallback-selection="view404"
role="main">
<home name="home"></home>
<listing name="listing"></listing>
<listing name="refine"></listing>
<detail name="detail"></detail>
<vrs-view404 name="view404"></vrs-view404>
</iron-pages>
哪裏是我的錯誤,以及如何從URL失去queryParams
預防?