vue.js v-for list not updating

后端 未结 3 1820
挽巷
挽巷 2021-02-12 09:50

I have this list:

  • {{ list.personName }}

And th

3条回答
  •  孤独总比滥情好
    2021-02-12 10:15

    Array change detection is a bit tricky in Vue. Most of the in place array methods are working as expected (i.e. doing a splice in your $data.names array would work), but assigining values directly (i.e. $data.names[0] = 'Joe') would not update the reactively rendered components. Depending on how you process the server side results you might need to think about these options described in the in vue documentation: Array Change Detection.

    Some ideas to explore:

    • using the v-bind:key="some_id" to have better
    • using the push to add new elements
    • using Vue.set(example1.items, indexOfItem, newValue) (also mentioned by Artokun)

提交回复
热议问题