routert.js 中:
<Router>
<Switch>
<Route exact path="/" component={Login}></Route>
<Route path="/*" component={Layout}></Route>
</Switch>
</Router>
在Layout 組件中:
<Router>
<Switch> <Route path={`/car/list`} component={car_list} /> <Route path={`/car/details`} component={car_details} /> <Route path={`/car/create`} component={car_create} /> </Switch>
</Router>
出現了從car/details 跳轉到 car/list 時出路徑改變但是頁面停留在car_details的問題,最終發現Layout組件中不能再出現<Router></Router>,否則就會出現上述問題。
最終將Layout組件改為:
<Switch>
<Route path={`/car/list`} component={car_list} />
<Route path={`/car/details`} component={car_details} />
<Route path={`/car/create`} component={car_create} />
</Switch>
每一個坑都是我成長的腳印。
