Due to limitations in JavaScript, Vue cannot detect the following changes to an array:
- When you directly set an item with the index, e.g.
vm.items[indexOfItem] = newValue
- When you modify the length of the array, e.g.
vm.items.length = newLength
Solution:
Vue.set(vm.items, indexOfItem, newValue)
orvm.$set(vm.items, indexOfItem, newValue)
vm.items.splice(indexOfItem, 1, newValue)
vm.items.splice(newLength)
Furthermore
var vm = new Vue({ |
is also not reactive.
Solution:
`Vue.set(object, key, value)`
for adding a number of new properties, you can use:
Object.assign(vm.userProfile, { |
P.S. (Object.assign == _.extend())
In another way:
vm.userProfile = Object.assign({}, vm.userProfile, { |