vue让元素滚动到指定位置

HTML部分

<div class="commodity-details" ref="commodityDetails"></div>

js部分

window.scrollTo({
    
    
    top: this.$refs['commodityDetails'].getBoundingClientRect().top + window.scrollY-70,
    behavior: 'smooth' // 平滑滚动
})

猜你喜欢

转载自blog.csdn.net/weixin_44949068/article/details/128669222