react 跳轉後路由變了頁面沒重新整理

2021-09-20 06:27:03 字數 1241 閱讀 6084

這樣的問題貌似原因還挺多的,我的問題是帶引數的url不能重新整理,router 5.0版本 ,使用withrouter關聯元件進行頁面跳轉

如下所示

路由**

在路由元件上最上層元素上加乙個key增加路由的識別度,因為普通的跳轉是根據path來識別的,但是path帶上引數時,路由無法精確識別。不過,在跳轉頁面的時候,每個位址都會在localtion物件裡新增乙個key。如下列印

// 元件掛載

我們將這個key繫結在 路由頂層元素上就能精確定位路由了

render()

>

"/" component=

/>

"/products/:id" component=

/>

"/about" component=

/>

"/solution" component=

/>

exact

path=

"/solutiondetails/:id"

component=

/>

"/download" component=

/>

"/about" component=

/>

"/details/:id" component=

/>

"/contact" component=

/>

/>

<

/switch>

<

/div>);

}import react,

from

"react"

;import

from

"react-router"

;class

routers

extends

component

render()

>

<

/div>);

}}export

default

withrouter

(routers)

;

react 顯示外部頁面 react 頁面跳轉

問題描述 頁面有跳轉詳情頁以及其他跳轉,其他跳轉都到了詳情頁 解決 路由順序改變一下,跳轉詳情頁的路由在其他同級路由最後 比如 會出問題的寫法 children 詳情頁跳轉路由 path id hidemenu true,name component 其他跳轉路由 path participatio...

使用vue進行登入後路由跳轉處理

接上文登入頁面編寫 登入成功後在components資料夾下新建home.vue home元件 div template export default script less scoped style router資料夾下index.js修改為 import vue from vue import ...

vue路由跳轉頁面

1.不帶引數 1 2 name,path都行,建議用name 3 42.帶引數5 6 params傳引數 類似post 7 路由配置 path home id 或者 path home id 8 不配置path 第一次可請求,重新整理頁面id會消失9 配置path,重新整理頁面id會保留 10 ht...