I'm trying to store data into local storage with Vue.js.
If I go into my main.js file and write localStorage.set('something', 5). I can see the data in my Chrome dev tools under 'Storage' in the 'Application' panel.
I want this to happen with my other data (the data I actually plan on using) but I don't see it. However, this code is stored under 'methods: {}' in my App.vue parent component. I'm gonna assume this is the problem but as I'm new to Vue I have no idea where to put my code so it will display in local storage in dev tools.
I'm displaying my code here to show its location, not its functionality.
// App.vue
data() {
return {
healthScore: 0,
storedHealthScore: 0
}
},
methods: {
setHealthScore() {
localStorage.setItem('HealthScore', this.healthScore)
},
getHealthScore() {
this.storedHealthScore = localStorage.getItem('HealthScore')
},
removeHealthScore() {
localStorage.removeItem('HealthScore')
}
}
Where do I need to place my code so that I will see this data in local storage?