Vue can track changes in ordinary objects.
<ul id="repeat-object" class="demo"> <li v-for="value in object"> {{ $key }} : {{ value }} </li></ul>
When traversing objects, it traverses according to the results of Object.keys(), but there is no guarantee that its results will be consistent under different JavaScript engines.
But if you want to add an attribute dynamically. For example,
obj['addProp'] = 'abcd'
vue has no way to track changes in the object.
You should use the $set method at this time and let Vue establish tracking. The first parameter is the value expression. , the second one is the value to be set.
this.$set("obj['addProp']", 'abcd')