React 路由(二)

77 阅读1分钟

//传递params参数 this.props.history.push(/home/message/list/${id}/${name}) //传递search参数 this.props.history.push(/home/message/list?id=${id}&name=${name}) //传递state参数 this.props.history.push(/home/message/list,{id,name})

(2)replace
//传递params参数
 this.props.history.replace(`/home/message/list/${id}/${name}`)
//传递search参数
 this.props.history.replace(`/home/message/list?id=${id}&name=${name}`)
//传递state参数
this.props.history.replace(`/home/message/list`,{id,name})
复制代码
(3)go
//num 正数表示前进。负数表示后退
this.props.history.go(num)
复制代码
(4)goBack
//后退一步
 this.props.history.goBack()
复制代码
(5)goForward
//前进一步
 this.props.history.goForward()
复制代码