1拿霉,事件
<div @click="goDingyue">立即訂閱</div>
2卸例,綁定事件
methods: {
goDingyue() {
// 獲取元素在頁(yè)面中的位置
console.log(this.$refs.dingyue_box_ref.getBoundingClientRect());
// document
// .getElementById("agentTitle")
// .scrollIntoView({ block: "start", behavior: "smooth" });
// 跳轉(zhuǎn)到指定位置并且平滑滾動(dòng)
this.$el
.querySelector(".dingyue_box")
.scrollIntoView({ block: "start", behavior: "smooth" });
},
}
3嫌吠,內(nèi)容
<div class="dingyue_box" ref="dingyue_box_ref">
立即訂閱內(nèi)容
</div>