报错Warning: You should not use and in the same route; <Route compone
react 路由之坑,非常坑
当以下情形就会报以上错误,
<Router>
<div className='app'>
<Switch>
{/* 如果路径是/ 就跳转到/home */}
<Redirect exact from='/' to ='/home'></Redirect>
<Route path='/home' component={Home}> </Route>
<Route path='/city' component={City}> </Route>
<Route path='/map' component={Map}></Route>
<Route component={NotFound}></Route>
</Switch>
</div>
</Router>
报错原因,Route组件之间不能有空格,或者换行,
要改成这样 或者直接是
竟然有这么奇葩的报错,还在网上搜到,Route组件下面不能嵌套Route组件,也会报这样的错误,希望能帮大家避坑
随便写写,希望有用,感恩有你