【发布时间】:2018-02-20 11:04:56
【问题描述】:
我们如何在 React-Router v4 中使用this.props.history.push('/page') 传递参数?
.then(response => {
var r = this;
if (response.status >= 200 && response.status < 300) {
r.props.history.push('/template');
});
【问题讨论】:
-
由
Route渲染的组件应该可以访问this.props.location、this.props.history等。我认为您不再需要在v4 中使用ref。尝试做this.props.history.push('/template'); -
不是 ref ,指向这个的是变量; this.props.history.push('/template');带我到下一页,但我想和他们一起传递道具 .ref = this;
-
您正在尝试将
props传递给与路由匹配的组件?我认为this GitHub thread 解决了您的问题。 -
您能否将其中一个回复标记为“答案”。我相信花时间打字的人会很感激。
标签: reactjs react-router