可以使用Set数据结构来确保数组中的字段key是唯一的。首先,将selectionRows数组转换为Set,然后将Set转换为数组并赋值给this.mustMiddlegroundDifArr数组。以下是示例代码:

// 将selectionRows数组转换为Set
const set = new Set(selectionRows.map(row => row.key));

// 将Set转换为数组并赋值给this.mustMiddlegroundDifArr数组
this.mustMiddlegroundDifArr = Array.from(set);

使用Set的特性可以确保数组中的字段key是唯一的,重复的值将被自动去重。

vue 将selectionRows数组赋值给thismustMiddlegroundDifArr数组并且保证thismustMiddlegroundDifArr数组中的字段key是唯一的不能重复赋值

原文地址: https://www.cveoy.top/t/topic/iE1A 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录