Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在react-router(尤其是react-router-native)中,是否可以从 的引用中获取对 的History对象的Router引用Router?(能够从任何地方路由?)
react-router
react-router-native
History
Router
我不认为你的问题很清楚,但我会提出我的想法。您可以从路由内调用的任何组件访问历史对象。此外,如果您想访问未在 Route 中调用的组件中的历史对象,只需从 react-router-dom 导入 withRouter,然后返回像这样包装的组件 withRouter(MyComponent)。