当我尝试访问 this.props.params
时,它是未定义的。 this.context.router
是 {}
。
我尝试了将 contextTypes 添加到我的组件的不同变体:
contextTypes: {
router: React.PropTypes.func.isRequired
}
但没有运气。
我的主要目标是将当前的 react-router url 传递给服务器。
最佳答案
如下所示:https://github.com/rackt/react-router/blob/v0.11.6/examples/query-params/app.js ,您需要添加 Router.State
混合宏:
var User = React.createClass({
mixins: [ Router.State ],
关于javascript - 如何在 react-router v1.0.0 中填充 this.props.params?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32764749/