簡體   English   中英

隱藏 url 中的查詢參數

[英]Hide query params from the url

我從一個組件導航到另一個組件並傳遞一些參數。 我也想傳遞查詢參數,但我不想在 url 中看到它。 我嘗試使用skiplocationchange,但后來成功了,但是當我們從父級導航到子級時,url 不會改變。 所以我不想使用skiplocationchange。

this._router.navigate(['/detailReports',id],{queryParams:{reportName : name},queryParamsHandling:"merge"});

所以在這里 reportName 我只希望它在路由器中,以便我以后可以得到這個道具。 但我不希望它顯示在 url 中。

你可以喜歡這個:

從頁面:

this.router.navigate(['/detailReports],{state:params})

到頁面:

constructor(){ let params = this.router.getCurrentNavigation().extras["state"] ? this.router.getCurrentNavigation().extras["state"] : "" constructor(){ let params = this.router.getCurrentNavigation().extras["state"] ? this.router.getCurrentNavigation().extras["state"] : "" } `

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM