>我想路由到react-router-1.0.3中渲染函数中的另一个路径。我可以通过使用以下方法提供链接来重定向用户:
render(
<Link to={`/${this.props.params.projectSlug}/`}>
Please follow this link to access your workspace.
</Link>
)
但我似乎无法以编程方式转发到此链接。我试过了:
render(
<Router history={browserHistory} routes=
{`/${this.props.params.projectSlug}/`}/>
)
如何以编程方式转发到 反应路由器 1.0.3 中的相对路径?
如果您
不介意,请尝试将路由器升级到最新版本;
然后,他们在这里严格说明如何做到这一点。
// Your main file that renders a <Router>:
import { Router, browserHistory } from 'react-router'
import routes from './app/routes'
render(
<Router history={browserHistory} routes={routes} />,
mountNode
)
&
// Somewhere like a Redux middleware or Flux action:
import { browserHistory } from 'react-router'
// Go to /some/path.
browserHistory.push('/some/path')
// Go back to previous location.
browserHistory.goBack()