0👍
You need to call Vue.set()
for arrays, and NOT use indexing such as
foo[3]= 'bar'
Vue DOES recognize some operations, such as splice
and push
, however.
Read more about it here: https://vuejs.org/2016/02/06/common-gotchas/ and here: https://v2.vuejs.org/v2/guide/list.html#Array-Change-Detection
So for your code, and using the Vue
handy helper method $set
:
this.validated.$set(name, true);
Why…
Javascript does not offer a hook (overload) for the array index operator ([]
), so Vue
has no way of intercepting it. This is a limitation of Javascript
, not Vue
. Here’s more on that: How would you overload the [] operator in javascript
Source:stackexchange.com