0
所以我有一个setRouteleaveHook与功能:如何使用终极版与routerWillLeave
routerWillLeave(nextLocation) {
// return false to prevent a transition w/o prompting the user,
// or return a string to allow the user to decide:
console.log("prompt: ", this.props.prompt);
if (this.props.prompt) {
return "Are you sure you wish to navigate? Unsaved data will be lost. Try to use the 'next' button instead if moving to the next part.";
} else {
return true;
}
}
this.props.prompt
是在商店的变量。看来,当我在它的父母中更新它时,prompt
在我下次访问它时才会被修改。
有没有更好的方法来触发这些提示? (鉴于它是执行router.push
的父组件)
this.props.router.setRouterLeaveHook(this.props.route,this.routerWillLeave) –
我的问题是没有得到绑定设置,我已经有了。我无法为我的孩子正确触发提示。尽管如此,接收商店更改正确。 –