I have array named List and created puted property putedList for him. When i update value of array it's not showing in html, but in console i see thar array is updated.
`/`
What is best way to use puted properties for array?
Maybe is exists way to trigger to re-render puted property?
I have array named List and created puted property putedList 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/apokjqxx/69/`
What is best way to use puted properties for array?
Maybe is exists way to trigger to re-render puted property?
Share Improve this question edited Jan 13, 2017 at 17:48 maxxdev asked Jan 13, 2017 at 17:43 maxxdevmaxxdev 3132 gold badges5 silver badges14 bronze badges 3- Some code would help. Do you have a jsfiddle showing the problem? Computed properties should work just fine and show updated values if the properties they reference update as well – georaldc Commented Jan 13, 2017 at 17:58
- Code is here jsfiddle/apokjqxx/69. Computed propertis working fine for object and not for arrays by default. – maxxdev Commented Jan 13, 2017 at 18:01
- 1 It's a vuejs limitation where it cannot pickup changes if you directly modify the array that way. vuejs/2016/02/06/mon-gotchas – georaldc Commented Jan 13, 2017 at 18:17
1 Answer
Reset to default 9Due 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.