methods: {
throttle(fn, wait) {
var timer = null;
return function () {
var context = this;
var args = arguments;
if (!timer) {
timer = setTimeout(function () {
fn.apply(context, args);
timer = null;
}, wait);
}
};
},
handle() {
let scroll_height = document.documentElement.scrollTop || document.body.scrollTop
scroll_height>=120 ? this.show = true : this.show = false
}
},
mounted() {
window.addEventListener("scroll", this.throttle(this.handle, 300));
},
destroyed(){
window.removeEventListener("scroll", this.throttle(),false);
},