当前路由停用后如何获取下一条路由? [英] How to get next route after the current route deactivate.?
本文介绍了当前路由停用后如何获取下一条路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
deactivate:function(){
this._super();
//这里的一些代码
}
有没有在路由停用之后,确定用户尝试去哪里(URL的路由)的方法?
解决方案
我建议您使用 willTransition
目的,因为这将在停用之前调用
钩子方法。
transition.targetName
将提供目标路线。
actions:{
willTransition(transition){
this._super(... arguments);
console.log('willTransition user',transition.targetName);
}
}
I have some code that uses route 'deactivate' method as follows.
deactivate: function() {
this._super();
//some code here
}
Is there a way to identify where is user trying to go(route of URL) after this route deactivates?
解决方案
I would encourage you to use willTransition
actions method hook for this purpose since that will be called before deactivate
hook method.
transition.targetName
will provide the target route.
actions: {
willTransition(transition) {
this._super(...arguments);
console.log('willTransition user ', transition.targetName);
}
}
这篇关于当前路由停用后如何获取下一条路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文