0👍
From what I see on the code, you may be resetting the local storage to your default data every time the component is mounted.
You should do the opposite on mounted, set your this.fieldsTest data = localStorage fieldsTest
, and then update localStorage
every time you change a checkbox.
Also make sure you have considered multiple users on the same browser because they might have different visibility options.
- [Vuejs]-Trying to use Virtual Scroller in Vue 3 But the items are buffering
- [Vuejs]-How to use default property value to define another property in Nuxt config?
0👍
I think you have to watch the fieldsTest
and if is there any changes in any of the object for visible property then set it into a local storage.
watch: {
fieldsTest: {
handler(newValue) {
localStorage.setItem('fieldsTest', JSON.stringify(newValue));
},
deep: true
}
}
Now, In mounted()
hook, You can load the data from localStorage back into the fieldsTest
array.
mounted() {
const updatedFieldsTest = JSON.parse(localStorage.getItem('fieldsTest'));
if (updatedFieldsTest) {
this.fieldsTest = updatedFieldsTest;
}
}
- [Vuejs]-Module '"vue-final-modal"' has no exported member 'ModalsContainer'.ts(2305)
- [Vuejs]-How to properly log out in Nuxt 3 / Vue JS?
Source:stackexchange.com