name: ‘test’,
data() {
return {
headerFixed: false,
}
},
mounted() {
window.addEventListener(‘scroll’, this.handleScroll)
},
destroyed() {
window.removeEventListener(‘scroll’, this.handleScroll)
},
methods: {
handleScroll() {
const scrollTop =
window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
this.headerFixed = scrollTop > 50
},
},
}