扫码关注官方订阅号
上拉刷新来实现分页,当有很多页的话,点击列表某一页去详细,然后从详情返回上一页,位置不能变,而且代码不会刷新,使用scrollBehavior还是算了,我用的是hash模式,有做过类似,希望能给点意见。
beforeRouteLeave(to, from, next){ let position = window.scrollY() this.$store.commit('SAVE_POSITION', position) //离开路由时把位置存起来 }
在页面中取值
mounted () { this.$nextTick(function(){ let position = this.$store.state.position //返回页面取出来 window.scroll(0, position) }) }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
在页面中取值