据我所知,<Route path="/" component={App} />
会给出App
与路由相关的道具,例如location
和params
。如果我的App
组件有许多嵌套的子组件,那么我如何在不使用以下子项的情况下让子组件访问这些道具:
- 从App传递道具
- 使用窗口对象
- 为嵌套的子组件创建路线
我以为this.context.router
会有一些与路线有关的信息,但this.context.router
似乎只有一些功能可以操纵路线。
会给出App与路由相关的道具,例如location和params。如果我的A..."> 会给出App与路由相关的道具,例如location和params。如果我的A..."/> 会给出App与路由相关的道具,例如location和params。如果我的A..."> 会给出App与路由相关的道具,例如location和params。如果我的A...">
react-router在子组件中获取this.props.location
据我所知,<Route path="/" component={App} />
会给出App
与路由相关的道具,例如location
和params
。如果我的App
组件有许多嵌套的子组件,那么我如何在不使用以下子项的情况下让子组件访问这些道具:
我以为this.context.router
会有一些与路线有关的信息,但this.context.router
似乎只有一些功能可以操纵路线。
第2161篇《react-router在子组件中获取this.props.location》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点
相似问题
问题类别