借助this.prosp.history对象上的API对操作路由跳转、前进、后退
this.prosp.history.push() 有记录 this.prosp.history.replace() 不留记录 this.prosp.history.goBack() 回退 this.prosp.history.goForward() 前进 this.prosp.history.go() -2 回退两步 1 前进一步
例子:
back = ()=>{
this.props.history.goBack()
}
forward = ()=>{
this.props.history.goForward()
}
go = ()=>{
this.props.history.go(-2)
}
push 跳转 例子
this.props.history.push(`/home/message/detail/${id}/${title}`)
this.props.history.push(`/home/message/detail?id=${id}&title=${title}`)
this.props.history.push(`/home/message/detail`,{id,title})
replace 跳转 例子
this.props.history.push(`/home/message/detail/${id}/${title}`)
this.props.history.push(`/home/message/detail?id=${id}&title=${title}`)
this.props.history.push(`/home/message/detail`,{id,title})
|