效果要求:
实现类似vant中滚动导航的效果:
储备知识,可以先看一下我之前的一篇文章:
client相关知识
1.通过计算排在tab前面元素的高度;
2.通过window.scrollTo()进行页面滚动。、
假设页面tab栏前面有两个class为head和mid的元素,则。
let headHeight = document.querySelector('.header');
let midHeight = document.querySelector('.mid');
let height = headHeight + midHeight;
window.screenTop(0,headHeight);
、