[Vuejs]-Component only updates when it is open

0👍

I’m not sure what you need to do inside that watcher, but if you’re using a Vuex store, wouldn’t be possible for you to do it inside of a mutation?

When the grandparent triggers a change in the store, inside the mutation you do the logic that is now inside the watcher.

0👍

If the actions you want to perform when the watcher triggers are local to your component, you can toggle the visibility of your component using v-show="someCondition", which will keep your component alive and active, but won’t show it. If you’re toggling it with v-if then it simply won’t exist until you click the dropdown.

Otherwise, if the actions you need to perform can be made outside of the component, you could perhaps move your watcher to the parent instead.

Read more about it here: https://vuejs.org/guide/essentials/conditional.html#v-show

Leave a comment