componentDidMount(){
this.props.router.setRouteLeaveHook(
this.props.route,
this.routerWillLeave
)
}
routerWillLeave=(nextLocation)=>{
return '确认要离开?';
}
刚接触react的小白,请问大佬们这样的路由钩子要怎么写
componentDidMount(){
this.props.router.setRouteLeaveHook(
this.props.route,
this.routerWillLeave
)
}
routerWillLeave=(nextLocation)=>{
return '确认要离开?';
}
刚接触react的小白,请问大佬们这样的路由钩子要怎么写
谢谢回复,我想实现的是在路由跳转之前根据要进入的路由信息获取数据,然后离开当前路由完成跳转,把数据渲染到下一个路由页面,之前在文档上注意到过这个prompt路由组件,觉得并不符合我的需求,敢问有什么建议呢