文章詳情頁
javascript - react-router-dom 跳轉問題js
瀏覽:75日期:2023-08-30 10:20:43
問題描述
設置內容如下:
<Route path='/first' component={First} /> <Route path='/first/:id' component={FirstDetail} />
問題是:在first頁面跳轉到first:/id頁面,不會刷新頁面,會追加內容。請問有什么好的方法?,這兩個路由對應的是不同的頁面
問題解答
回答1:import {Switch} from ’react-router-dom’;....<Switch> <Route path='/first' exact component={First} /> <Route path='/first/:id' component={FirstDetail} /></Switch>
標簽:
JavaScript
相關文章:
排行榜
