Vue makes the element scroll to the specified position

HTML part

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

js part

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

Guess you like

Origin blog.csdn.net/weixin_44949068/article/details/128669222