I attempted to implement a fixed div on scroll in Vue.js using the following code:
...
async created() {
window.addEventListener('scroll', this.calendarScroll);
}
methods: {
calendarScroll() {
console.log('Scroll');
const dateHeader = document.querySelector('.dates-header');
if (dateHeader) {
if (window.scrollTop() >= 200) {
dateHeader.style.top = 0;
dateHeader.style.position = 'fixed';
}
}
},
}
The issue that arises is:
Calendar.vue?404a:681 Uncaught TypeError: window.scrollTop is not a function