最近写项目的时候,发现做一个吸顶效果只有chrome可以获取到滚动的值,其他浏览器都是0
结局方案
做一个兼容性操作即可
let top = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
if(top > this.$refs.filmSwiper.$el.offsetHeight)
{
this.isFixed = true;
// console.log('fixed')
}
else{
this.isFixed = false;
// console.log('unfixed')
}
}