search

Home  >  Q&A  >  body text

javascript - Vue2 new array overwrites old array problem

For example, old = [1,3,4,5]; new = [212,43,54,23];
Use new to overwrite old, Vue can detect changes in the array and re-render the data

我想大声告诉你我想大声告诉你2863 days ago560

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-05-19 10:24:42

    Vue has a section dedicated to this

    reply
    0
  • PHPz

    PHPz2017-05-19 10:24:42

    Yes, as long as old is responsive, replacing it with new will trigger set, and Vue can make new and the elements inside responsive.

    Like old[233] = 1 because old[233] is originally undefined and Vue cannot detect it without binding get and set.

    For more information, please see the documentation
    https://cn.vuejs.org/v2/guide...
    https://cn.vuejs.org/v2/guide...

    reply
    0
  • Cancelreply