mounted () {
window.addEventListener('scroll', this.handleScroll, true)
},
methods: {
toTop () {
let top = document.documentElement.scrollTop || document.body.scrollTop
// 实现滚动效果
const timeTop = setInterval(() => {
document.body.scrollTop = document.documentElement.scrollTop = top -= 50
if (top <= 0) {
clearInterval(timeTop)
}
}, 10)
},}
vue返回顶部
最新推荐文章于 2023-09-04 10:22:10 发布