这是我的路线上的配置代码:反应路由器Dom参数无法正常工作?
<Switch>
<Route exact path='/(home)?' component={TodoListHomePage} />
<Route exact path='/profile/:userId' component={TodoListProfilePage} />
<Route path='/login' component={SignUpAndLogin} />
</Switch>
一切工作正常,但与PARAM路径怪异,在第一次单击它例如工作正常,路径
二号点击它加到配置文件是这样的:
http://localhost:4000/Profile/Profile/597c1f43a87ca40d38f79a68
和上上如
http://localhost:4000//Profile/Profile/Profile/Profile/597c1f43a87ca40d38f79a68
这是在点击档案链接时,我的函数调用:
handleProfileClick = (e, {name}) => {
this.setState({ activeItem: name });
this.props.history.push(name.concat('/'.concat(this.props.viewer._id.toString())));
}
您使用相对路径。只需在连接之前添加'/ profile'。 –