window.scrollTo({
//滚动到元素位置
//top: this.$refs[元素].offsetTop,//offsetTop 相对于offsetparent 定位,当有定位时,不准确。
top: this.$refs[元素].getBoundingClientRect().top + window.scrollY,//推荐使用,getBoundingClientRect 相对于当前视口的位置
//top: 400//滚动到指定距离
//top: 0,//滚动到顶部
//top: document.documentElement.scrollHeight,//滚动到底部
behavior: "smooth" // 平滑滚动
});
vue 滚动条平滑滚动到某个位置
最新推荐文章于 2024-04-23 15:11:05 发布