fixed兼容性
当发生下拉或上拉操作时,fixed会发生一些兼容性问题。
可以通过监听某元素的滚动条位置,来改变该元素的css,属性由fixed改为absolute;
vue中监听滚动条位置
methods: {
handleScroll(){
//监听相应滚动条的位置
let scroll = document.querySelector('.common-container').scrollTop
}
},
mounted() {
window.addEventListener('scroll',this.handleScroll,true)
},
destroyed(){
window.removeEventListener('scroll',this.handleScroll,true)
}