Riy*_*ria 3 reactjs react-router react-router-v4
我想为我的下一页传递多个状态,我正在从另一个页面重定向。
一个我已经通过了,而且工作正常。
<Link to ={{pathname: "/CreateEventUser", state: { bucket_id: !this.state.selected_bucket.id ? this.state.recent_bucket : this.state.selected_bucket } }} >
<button type="button" className="btn btn-danger">Create an Event</button>
</Link>
Run Code Online (Sandbox Code Playgroud)
现在我必须通过两个状态。它的语法是什么?
<Link to ={{pathname: "/EventDetailsUser", state: { bucket_id: !this.state.selected_bucket.id ? this.state.recent_bucket : this.state.selected_bucket, eventId: event.id}}} >
Run Code Online (Sandbox Code Playgroud)
Shu*_*tri 10
state
位置路径名中的参数除了和对象之外,因此您可以根据需要传递尽可能多的值,方法是将 then 作为对象传递,例如
<Link to ={{
pathname: "/CreateEventUser",
state: {
bucket_id: !this.state.selected_bucket.id ? this.state.recent_bucket : this.state.selected_bucket,
new_id: this.state.newID,
anotherValue: this.state.anotherValue
}
}} >
<button type="button" className="btn btn-danger">Create an Event</button>
</Link>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7486 次 |
最近记录: |