I am working on a hamburger menu. But i've got an error. It gives the next
ReferenceError: window is not defined. The fault is in the created section.
<script>
export default {
name: "navigation",
data() {
return {
scrollPosition: null,
mobile: null,
mobileNav: null,
windowWidth: null,
};
},
created() {
window.addEventListener("resize", this.checkScreen);
this.checkScreen();
},
methods: {
toggleMobileNav() {
this.mobileNav = !this.mobileNav;
},
checkScreen() {
this.windowWidth = window.innerWidth;
if (this.windowWidth <= 750) {
this.mobile = true;
return;
}
this.mobile = false;
this.mobileNav = false;
return;
},
},
};
</script>