我在使用react路由器v4实现react本机内的嵌套路由时遇到了问题。
如果嵌套路由是在App.js中声明的,那么它可以正常工作,但是当它在另一个组件中声明时,重定向不起作用。
我试图在这里跟踪文档:https://reacttraining.com/react-router/core/guides/philosophy/nested-routes
是简单的事情吗?
我创建了一个简单的回购程序,它拥有所有要复制的代码:
git clone https://github.com/814k31/TestReactNativeRoutingv4.gitcd TestReactNativeRoutingv4npm installnpm run <platform>发布于 2018-04-14 05:37:40
感谢康科德的反应人员
我需要使用相对链接,否则路由器将在根组件(App.js)中查找路由,并且不知道嵌套路由。
const Tacos = ({ match }) => ( // here's a nested div <div> <Route exact path={`${match.url}/Carnitas`} // The "match.url" is critical here component={Carnitas} /> TACOS <Redirect to={`${match.url}/Carnitas`} push /> // And here </div> )
https://stackoverflow.com/questions/49813292
复制相似问题