I am currently working on developing a hamburger menu, but I have encountered an error. The error message states:
ReferenceError: window is not defined. The issue seems to be within the created section of the code.
<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>