[Vuejs]-V-bind:class not working with array variables

3👍

This is one of the “Vue Gotchas”

https://vuejs.org/2016/02/06/common-gotchas/

From “Why isn’t the DOM updating?”

When you modify an Array by directly setting an index (e.g. arr[0] = val) or modifying its length property. Similarly, Vue.js cannot pickup these changes. Always modify arrays by using an Array instance method, or replacing it entirely. Vue provides a convenience method arr.$set(index, value) which is syntax sugar for arr.splice(index, 1, value).

Leave a comment