【发布时间】:2017-07-17 13:41:18
【问题描述】:
在我有<Route> 代码的 SideMenuNavigation 组件上,我需要访问this.props.location.pathname 的值。不幸的是,我收到了undefined。
class SideNavigation extends React.Component {
componentDidMount() {
console.log(this.props.location.pathname); // undefined
}
render() {
return(
<Router>
<Route exact path="/" component={Dashboard}/>
</Router>
)
}
}
/* */
在我的仪表板组件中,我可以成功访问this.props.location.pathname。不幸的是,我不需要这个组件。我需要SideMenuNavigation 组件中的值。
【问题讨论】:
标签: reactjs react-router