Answer the question
In order to leave comments, you need to log in
Why is Vue's @scroll event not firing?
Why is Vue's @scroll event not firing? And how to make it work?
Here is the document, root is the Vue scope
<body>
<div id="root">
<div @scroll="hideHeader" class="all-wrapper">
<div class='header-sticky' :class="{'header-show': isShowHeader}">
<div class="logo">
new Vue({
el: root,
data:{
isAdvantageMore: false,
currentAdv: '',
isShowHeader: true
},
methods:{
openAdvantageMore(value){
this.isAdvantageMore = !this.isAdvantageMore;
this.currentAdv = value;
document.body.style.overflow = this.isAdvantageMore? "hidden" : "auto";
},
hideHeader(){
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
this.isShowHeader = scrollTop > 100 ? false : true;
console.log(this.isShowHeader);
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question