methods:{
handleScroll() {
this.scrollHeigh =this.$refs.scorll_top.getBoundingClientRect().left
conlog.log('移动了' , this.scrollHeigh)
}
//监听
mounted: function () {
document.querySelector(".menu").addEventListener('scroll', this.handleScroll, true)
},
//去除监听
beforeDestroy: function () {
windows.removeEventListener('scroll', this.handleScroll,true) //必须使用否则报错
},