報錯/Warning: You should not use and in the same route; will be ignored


這個報錯在以下情形會出現

第一種

<Switch>
       <Route exact path="/home/index" component={HomeIndex} />
       <Route path="/home/order" component={HomeOrder}>
          <Route path="/home/order2" component={HomeOrder2}></Route>
       </Route>
       <Route path="/home/assets" component={Assets} />
    </Switch>    

Route組件下面不能嵌套Route組件,react-router4版本以上就不讓這么寫了

第二種(超級坑!!!)

<Switch>
       <Route exact path="/home/index" component={HomeIndex} />
       <Route path="/home/order" component={HomeOrder}>
       </Route>
       <Route path="/home/assets" component={Assets} />
    </Switch> 

Route組件之間不能有空格換行!所以,要么<Route></Route>這種樣子或者寫成一個自閉和標簽<Route />!!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM