Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuejs2: How to re-render array computed properties when array changed

I have array named List and created computed property computedList for him. When i update value of array it's not showing in html, but in console i see thar array is updated.

`https://jsfiddle.net/apokjqxx/69/`   

What is best way to use computed properties for array?

Maybe is exists way to trigger to re-render computed property?

like image 765
maxxdev Avatar asked Jan 13 '17 17:01

maxxdev


1 Answers

Due to limitations in JavaScript, Vue cannot detect the changes to an array like this: this.list[1] = 'vueman'

You have to use Vue.set or vm.$set as explained here to trigger state updates in the reactivity system, like follwoing:

  this.$set(this.list, 1, 'vueman')

see updated fiddler here.

like image 51
Saurabh Avatar answered Sep 22 '22 05:09

Saurabh