修复 tools 工具类的错误
This commit is contained in:
parent
abf0007167
commit
57d3f7aead
|
|
@ -11,7 +11,7 @@ export const forEach = (arr, fn) => {
|
|||
/**
|
||||
* @param {Array} arr1
|
||||
* @param {Array} arr2
|
||||
* @description 得到两个数组的并集, 两个数组的元素为数值或字符串
|
||||
* @description 得到两个数组的交集, 两个数组的元素为数值或字符串
|
||||
*/
|
||||
export const getIntersection = (arr1, arr2) => {
|
||||
let len = Math.min(arr1.length, arr2.length)
|
||||
|
|
@ -27,7 +27,7 @@ export const getIntersection = (arr1, arr2) => {
|
|||
/**
|
||||
* @param {Array} arr1
|
||||
* @param {Array} arr2
|
||||
* @description 得到两个数组的交集, 两个数组的元素为数值或字符串
|
||||
* @description 得到两个数组的并集, 两个数组的元素为数值或字符串
|
||||
*/
|
||||
export const getUnion = (arr1, arr2) => {
|
||||
return Array.from(new Set([...arr1, ...arr2]))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<script>
|
||||
import sideMenuItem from './side-menu-item.vue'
|
||||
import collapsedMenu from './collapsed-menu.vue'
|
||||
import { getIntersection } from '@/libs/tools'
|
||||
import { getUnion } from '@/libs/tools'
|
||||
import mixin from './mixin'
|
||||
export default {
|
||||
name: 'sideMenu',
|
||||
|
|
@ -72,7 +72,7 @@ export default {
|
|||
watch: {
|
||||
activeName (name) {
|
||||
if (this.accordion) this.openedNames = this.getOpenedNamesByActiveName(name)
|
||||
else this.openedNames = getIntersection(this.openedNames, this.getOpenedNamesByActiveName(name))
|
||||
else this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName(name))
|
||||
},
|
||||
openNames (newNames) {
|
||||
this.openedNames = newNames
|
||||
|
|
@ -84,7 +84,7 @@ export default {
|
|||
}
|
||||
},
|
||||
mounted () {
|
||||
this.openedNames = getIntersection(this.openedNames, this.getOpenedNamesByActiveName(name))
|
||||
this.openedNames = getUnion(this.openedNames, this.getOpenedNamesByActiveName(name))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue