samfrjn119 years agoLevel 3ReplyReport SpamSimply add an event listener as soon as the component is mounted. If you are using vue <2.0 replace mounted with ready. export default{ mounted(){ window.addEventListener("scroll", runOnScroll); }, methods: { myMethod(){ console.log('scroll!'); } } } Like Reply 1 like
wood4283 OP 9 years ago Best Answer Level 20ReplyReport Spam@samfrjn11 Thanks. However, I had to add the event listener to my method and then return the function within the callback. When I tried to call my method the way you have it, it would only call it once when it mounted. export default{ mounted(){ this.myMethod(); }, methods: { myMethod(){ window.addEventListener("scroll", function(){ console.log('scrolling'); } } } } Like Reply 2 likes