0
我想检查路径路径的to
和from
与scrollBehavior
管理滚动行为。Vue路由器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',
});
想,我从浏览关于页面向在列表内或您的列表页,我想return {x: 0, y: 0}
。但是,当在列表或之间导航时,您的列表我不想要这样的行为。
但是,to
和from
都返回相同的路径。他们都返回to.path
,所以我无法检查它在哪里导航from
。我在这里错过了什么?