mounted() {
window.addEventListener('scroll', this.scrollToTop);
},
destroyed() {
window.removeEventListener('scroll', this.scrollToTop);
},
methods(){
scrollToTop() {
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
},
//点击函数
change: function (index) {
this.current = index;
//获取热门分类高度
vuedata.hotHeight = document.getElementById("life-right-top").offsetHeight;
//获取二级分类高度
var seHeight = $api.domAll('#getHeight');
for (var i = 0; i < seHeight.length; i++) {
vuedata.secondHeight.push(seHeight[i].clientHeight)
}
if (this.current == -1) {
//设置高度
window.pageYOffset = document.body.scrollTop = document.documentElement.scrollTop = 0;
} else {
var jumpHeight = vuedata.hotHeight + 20;
for (var n = 0; n < this.current; n++) {
jumpHeight += vuedata.secondHeight[n];
}
//设置高度
window.pageYOffset = document.body.scrollTop = document.documentElement.scrollTop = jumpHeight;
// document.querySelector('#right').scroll(0,jumpHeight)
}
},
}
网友评论