[英]horizontal scroll behaviour in vue.js on anchor link click event
I am working in vue frame work.I have an issue with scroll behavior , whenever clicking the side menu . 我在Vue框架中工作。每当单击侧面菜单时,滚动行为就会出现问题。 In my web application I have side navigation bar towards left side of the screen and the corresponding content panel in the middle of the page . 在我的Web应用程序中,我具有靠近屏幕左侧的侧面导航栏和位于页面中间的相应内容面板。 you can check the image i have added. 您可以检查我添加的图像。
so whenever i click the side menu , it reaches to the corresponding panel. 因此,每当我单击侧面菜单时,它就会到达相应的面板。
The vertical scroll bar is working fine , but I have issues with horizontal scroll bar. 垂直滚动条工作正常,但是水平滚动条存在问题。
The horizontal scroll bar gets scrolled bit towards middle of the page. 水平滚动条向页面中间滚动。
expected behavior 预期行为
whenever i click. 每当我点击。 The horizontal scroll should remain always in the left , 水平滚动条应始终保持在左侧,
my current code 我当前的代码
scrollBehavior(to, from, savedPosition) {
if (to.hash) {
return { selector: to.hash };
} else if (savedPosition) {
return savedPosition;
}
return { x: 0, y: 0 };
},
我认为scrollBehavior (to, from, savedPosition)
的功能scrollBehavior (to, from, savedPosition)
可能会有所帮助。
if (to.hash) {
return {
selector: to.hash,
offset: { x: the main content element value in my case it was 204.2, y:0 },
};
} else if (savedPosition) {
return savedPosition;
}
return { x: 0, y: 0 };
},
it worked 有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.