I am developing an application using Vuejs/Nuxtjs
In this application I have a component IdentifiersNode.vue
where I want to monitor the Vuex storage array identifiersArray
.
I can observe direct changes to identifiersArray
such as push, direct key value changes
, but when I add new objects to the objects in identifiersArray
, watch
will cause
If you use vuex, I recommend using
mapGetters
to get your items from the store. This will automatically monitor the value and re-render every time the item changes.Here is the documentation: Documentation
Small example
shop
Component
The following is a codepen as an example: https://codesandbox.io/s/vuex-store-forked-bl9rk0?file=/src/components/HelloWorld.vue
If you want %E
Providing an answer may help others in the future.
I'm actually appending the object to an existing object in an array in the Vuex Store. Therefore, the watch cannot recognize the change. I changed it to
vue.set
and this worked for me.Previously I used append to existing object:
Later I changed it to:
The following is my Vue component.