我想检查to
和from
路由路径与scrollBehavior
管理的滚动行为。
global.router = new VueRouter({
routes,
scrollBehavior(to, from, savedPosition) {
console.log('>>> to', to);
console.log('>>> from', from);
switch (to.path) {
case '/in-list':
break;
case '/your-list':
break;
default:
return {x: 0, y: 0}
}
},
mode: 'history',
});
假设,我从“关于”页面导航到“ In-List”或“ Your-list”页面,我想return {x: 0, y: 0}
。但是,在In-list或Your-list之间导航时,我不希望出现这种行为。
然而,无论是to
和from
返回相同的路径。他们都返回了to.path
所以我无法检查它是在哪里导航的from
。我在这里缺少什么?
好的,所以问题出在我的版本上。我正在使用^2.2.1
并升级到最新版本2.7.0
。但是,此问题已在版本中修复2.3.1
。
我在Vue-router的已关闭问题中看到了这个问题。希望这会帮助某人。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句