Does Vue.js have a built in way to add a copy of a persistent object to a repeated array

后端 未结 4 1433
逝去的感伤
逝去的感伤 2020-12-03 07:28

I have a Vue.js app where I have a v-repeat on an array of items. I want to add a newItem to the list of items. When I try this.items.push(this.newItem) the obj

4条回答
  •  旧时难觅i
    2020-12-03 07:46

    This didn't work for me (vue 1.0.13). I used the following to create a copy without the data bindings:

    this.items.push( JSON.parse( JSON.stringify( newItem ) ) );
    

提交回复
热议问题