我的代码存在问题
我的路线档案的一部分
let routes = (
<Route name="app" path="/" component={App}>
<IndexRoute component={homePage}></IndexRoute>
<Route name="author" path="author" component={authorPage}></Route>
<Route name="about" path="about" component={about} onEnter =
{AboutPageHelper.onEnteringAboutPage} onLeave =
{AboutPageHelper.onLeaveAboutPage}></Route>
<Redirect from="aboat" to="about"></Redirect>
<Route path="*" component={NotFoundPage}></Route>
</Route>
)
和我的助手功能
var onEnteringAboutPage = function(location, replaceWith){
console.log('here');
}
var onLeaveAboutPage = function(location, replaceWith){
console.log('twice')
if(confirm('Are you sure you want to leave this super excitement?'))
{
console.log('lets leave');
}
else{
console.log('here to stay');
}
}
问题是这个onLeave函数在离开页面时被调用两次以及如何在确认对话框上按下取消时停止导航?
非常感谢,祝你有个美好的一天:)