I'm having issues with initialising my Vue component with data from localStorage. Here is a simplified version of my code
new Vue({
el: "#my-element",
created: () => {
if (window.localStorage.getItem("verified")) {
this.verification.verified = true;
}
},
data: {
verification: {
verified: false
}
}
});
But I keep getting an error on the console Cannot read property 'verification' of undefined
If I put a debugger in the created() function, and I check the values of this, this.verification and this.verification.verified, they're all set to the values I have initialized with in the data object.
Can someone explain what I am doing wrong?
Basically I'm trying to hide an element when the page loads if the user has already gone through the verified process at any previous time.