【发布时间】:2020-07-29 09:55:56
【问题描述】:
案例 1: 重定向到同一选项卡中的新路线。
<Link to={{ pathname: "/modify_items", state: { foo: "bar" } }} >
当我输入 console.log(this.props.location.state); 时,状态 { foo: "bar" } 会被打印出来。
案例 2: 重定向到新标签中的新路线。
<Link to={{ pathname: "/modify_items", state: { foo: "bar" } }} target="_blank" >
当我输入console.log(this.props.location.state); 时,状态变为undefined。
我的目标是将数据传递到新选项卡。如果有任何其他方法可以在 React.js 中实现这一点,请指导我。我只想将数据传递到新标签页。
【问题讨论】:
-
您找到解决方案了吗?
-
我现在使用 localstorage @sçuçu。但这不是我想要的。虽然它的工作原理
-
是的,localStorage 似乎是一种高性能且受支持的方式。我还有一些建议,下面是我的 naswer 中的主要链接。希望大家多多指教。
标签: reactjs react-router