<header></header>
<div class="content" ref="swiperContent">
//滚动内容页面
</div>
<footer></footer>
// 一进页面滚动到指定位置
animate(element, target) {
clearInterval(element.timeId)
var current = 0
element.timeId = setInterval(function () {
var step = (target - current) / 10
step = step > 0 ? Math.ceil(step) : Math.floor(step)
current += step
element.scrollTo(0, current)
if (current == target) {
clearInterval(element.timeId)
}
}, 10)
},
//调用
this.animate(this.$refs.swiperContent,300) //向上滚动300px
vue一进页面滚动到指定位置
最新推荐文章于 2024-09-03 15:38:58 发布