I've written a basic component just to display my component once I scroll past it's position, so obviously this will be a sticky navigation.
I'm getting the following error:
TypeError: Cannot read property 'remove' of undefined"
So obviously this.$el
is undefined however it shouldn't be!
Below is my component:
<script>
export default {
data: function() {
return {
display: true,
element: null
}
},
render() {
return this.$scopedSlots.default({
display: this.display
});
},
mounted() {
window.onscroll = this.func();
},
methods: {
func: function() {
let sticky = this.$el.offsetTop;
if (window.pageYOffset > sticky) {
this.$el.classList.add("sticky");
this.display = true;
} else {
this.$el.classList.remove("sticky");
this.display = false;
}
}
}
}
</script>