在 react-router v1.0 中 Router.create (react-router v0.13) 的等价物是什么?
What is the equivalent of Router.create (react-router v0.13) in react-router v1.0?
var router = Router.create({ routes: routes, location: null // Router.HistoryLocation });我想为要在 DOM 之外使用的路由器创建一个引用.
I want to create a reference for the router to be used outside of the DOM.
router.transitionTo('app');上面的代码片段是 v0.13 中的代码片段.想知道是否有人知道如何在 react-router v1.0 中编写它们.
The code snippet above is the ones in v0.13. Wondering if anyone knows how to write them in react-router v1.0.
我已经浏览了 react-router 的文档,我找到了 createRoutes 函数.我不知道如何使用它.请帮我解决这个问题.
I have gone through the documentation of react-router, and I had found the createRoutes function. I had no idea how to use it. Please help me on this.
推荐答案从 v1.0 开始,React Router 现在比这更加模块化.导航之类的东西是历史"对象的功能,而不是路由器本身,它只处理路由.
React Router as of v1.0 is now more modular than that. Things like navigation are functions of a "history" object rather than the router itself, which only handles routing.
要使用 React Router v1.0 执行等效操作,您可以在路由器外部实例化 history 对象,然后用它做任何您想做的事情.在组件外部导航指南中提供了更详细的文档:github/rackt/react-router/blob/master/docs/guides/advanced/NavigatingOutsideOfComponents.md.
To do the equivalent with React Router v1.0, you would instantiate the history object outside the router, then do whatever you want with it. There's more detailed documentation available at the guide for navigating outside of components: github/rackt/react-router/blob/master/docs/guides/advanced/NavigatingOutsideOfComponents.md.
更多推荐
反应路由器 v1.0.0 中的 Router.create
发布评论