简体   繁体   English

在Vue.js中替换可观察数组的方式是什么?

[英]What would be the way to replace a observable array in Vue.js?

Instead of just assigning newGroups. 而不只是分配newGroups。 How would it be done with Vue.$set to keep the observable array ? 如何使用Vue。$ set保留可观察数组?

   this.groups = newGroups;

Use splice . 使用拼接 This works nicely with the spread syntax 这很好地与传播语法配合使用

this.groups.splice(0, this.groups.length, ...newGroups);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM