In my Vue 2 application, there is a state variable named boxes
which stores an array of box objects. A computed property called nearest_box_linked_boxes
extracts a subset of these boxes.
There is a method that goes through the boxes obtained from nearest_box_linked_boxes
and updates a property in each element:
for(let i=0;i<this.nearest_box_linked_boxes.length;i++)
{
let box = this.nearest_box_linked_boxes[i];
box.object_class = this.$store.state.selected_object_class;
box.patch();
}
However, this method is throwing an error:
vue.esm.js:648 [Vue warn]: Error in v-on handler: "TypeError: Cannot assign to read only property 'object_class' of object '#<Box>'"
I did not explicitly set any of the box objects or their properties as read-only. While I understand that I cannot directly write to nearest_box_linked_boxes
since it's a calculated property, I believed it should be possible to modify the properties of each element within the array.
Could this issue be related to Vue and how it handles calculated properties, or is there something else at play?