1、关于扁平化数组
const deps = { 'A组':[1,2,3], 'B组':[5,8,12], 'C组':[5,14,79], 'D组':[3,64,105], } let member = Object.values(deps).flat(Infinity);
其中使用Infinity作为flat的参数,使得无需知道被扁平化的数组的维度。
补充
flat方法不支持IE浏览器。
2、关于输入框非空的判断
if((value??'') !== ''){ //... }
3、关于合并数据
const a = [1,2,3]; const b = [1,5,6]; const c = [...new Set([...a,...b])]; //[1,2,3,5,6] 数组的合并考虑去重 const obj1 = { a:1, } const obj2 = { b:1, } const obj = {...obj1,...obj2}; //{a:1,b:1}