I have a very simple app, that has 2 components: the App.vue
and another component, Home.vue
where I hold the rest of the structure of the app: a stick
window
properties can't be used reactively like that. Instead, you'd have to listen to the window
's scroll
event and respond accordingly:
mounted() {
window.addEventListener("scroll", this.onScroll)
},
beforeDestroy() {
window.removeEventListener("scroll", this.onScroll)
},
methods: {
onScroll(e) {
this.windowTop = window.top.scrollY /* or: e.target.documentElement.scrollTop */
}
}