Vue: 如何将数组赋值给另一个数组并去除重复元素
您可以使用 Set 数据结构来实现将 selectionRows 数组赋值给 this.mustMiddlegroundDifArr 数组,并确保 this.mustMiddlegroundDifArr 不重复赋值的需求。
首先,将 selectionRows 数组转换为 Set 数据结构,以去除重复元素。然后,将 Set 转换为数组,并赋值给 this.mustMiddlegroundDifArr 数组。
以下是具体的代码示例:
this.mustMiddlegroundDifArr = Array.from(new Set(selectionRows));
这样,就可以将 selectionRows 数组赋值给 this.mustMiddlegroundDifArr 数组,并且保证 this.mustMiddlegroundDifArr 不重复赋值。
原文地址: https://www.cveoy.top/t/topic/qlB0 著作权归作者所有。请勿转载和采集!