【发布时间】:2018-06-17 05:45:37
【问题描述】:
例如:
import SomeComponent...
<Router>
<Route path='/' component={SomeComponent} />
</Router>
如何将某些内容传递给SomeComponent,以便我可以通过this.props.xxx 在组件中访问它?
【问题讨论】:
-
好吧,你在
<Route标签上使用render属性(而不是component属性),或者你使用redux 之类的东西并创建一个连接的组件,或者使用一个HOC注入一些应该始终可用的数据,有很多选择;)
标签: javascript reactjs ecmascript-6 react-router react-router-v4