Vue.js computed property not updating Vue.js computed property not updating vue.js vue.js

Vue.js computed property not updating


If your intention is for the computed property to update when project.classes.someSubProperty changes, that sub-property has to exist when the computed property is defined. Vue cannot detect property addition or deletion, only changes to existing properties.

This has bitten me when using a Vuex store with en empty state object. My subsequent changes to the state would not result in computed properties that depend on it being re-evaluated. Adding explicit keys with null values to the Veux state solved that problem.

I'm not sure whether explicit keys are feasible in your case but it might help explain why the computed property goes stale.

Vue reactiviy docs, for more info:https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats


I've ran into similar issue before and solved it by using a regular method instead of computed property. Just move everything into a method and return your ret.Official docs.


I had this issue when the value was undefined, then computed cannot detect it changing. I fixed it by giving it an empty initial value.

according to the Vue documentation

enter image description here