<div class="box">1</div>
<van-sticky :offset-top="navbarHeight">
<van-button type="primary">基础用法</van-button>
</van-sticky>
<div class="box">2</div>
export default {
data() {
return {
navbarHeight:0,
}
},
mounted() {
console.log(document.querySelector(".page-header").offsetHeight)//获取导航条的高度
this.navbarHeight = Number(document.querySelector(".page-header").offsetHeight);//吸顶的距离
},
methods: {
},
}