vue切换路由后让页面从头部开始显示的方法

官方文档的方法:https://router.vuejs.org/zh/guide/advanced/scroll-behavior.html
如果实在不行可以试试下面的:
在methods:{}中定义方法:
toTop() { window.scrollTo(0,0); },
在组件创建时created()钩子函数中调用toTop,
this.toTop()
版权声明:
作者:东明兄
链接:https://blog.crazyming.com/note/480/
来源:CrazyMing
文章版权归作者所有,未经允许请勿转载。


共有 0 条评论