原因解析
vue项目中,页面/路由跳转后,body 的内联样式变成 overflow:hidden
解决方案
使用路由守卫,在页面/路由跳转后,将body 的overflow设置为auto
src/main.js
// 解决bug:页面/路由跳转后,滚动条消失,页面无法滚动 router.afterEach((to, from, next) => { document.querySelector("body").setAttribute("style", "overflow: auto !important;") });
更多路由守卫的使用方法,参考博文 https://blog.csdn.net/weixin_41192489/article/details/117409477