[Vuejs]-Computed property doesn't kick in, Vue js

0👍

It looks like you’re just having problems with the reactivity caveats.

For objects: https://v2.vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats

For arrays: https://v2.vuejs.org/v2/guide/list.html#Caveats

Assuming this.selectedZonesTest is an array you can’t set a value by index like this:

this.selectedZonesTest[this.boneId] = [this.zoneId];

Instead you need to do something like this:

Vue.set(this.selectedZonesTest, this.boneId, [this.zoneId]);

Or you can use the splice method:

this.selectedZonesTest.splice(this.boneId, 1, [this.zoneId]);

These are limitations of the way Vue 2 detects changes. Vue 3 will use a different technique for change detection that will remove these caveats.

Leave a comment