常用的工具函数
得到兩個(gè)數(shù)組的并集, 兩個(gè)數(shù)組的元素為數(shù)值或字符串 //tools.js
export const getUnion = (arr1, arr2) => {return Array.from(new Set([...arr1, ...arr2]))
}//調(diào)用頁面
import { getUnion } from '@/libs/tools'this.getUnion = getUnion([1,2,3,5],[1,4,6])
//(6) [1, 2, 3, 5, 4, 6]// 示例 this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName(name)) // 回調(diào)函數(shù)
getOpenedNamesByActiveName (name) { return this.$route.matched.map(item => item.name).filter(item => item !== name)
}
轉(zhuǎn)載于:https://www.cnblogs.com/LFxanla/p/11171917.html
總結(jié)
- 上一篇: 做梦梦到黑蛇追我是什么意思
- 下一篇: sqlserver 批量处理数据