前端小技巧之 --- 节点的主题是否相同?

要判断一下两个数组中节点的主题是否相同?

 

 

方法:

created() {
    let re1 = this.ifSameTheme(this.treeList1)
    console.log("是否相同?--treeList1:", re1)
    let re2 = this.ifSameTheme(this.treeList2)
    console.log("是否相同?--treeList1:", re2)
  },
  methods: {
    ifSameTheme(list) {
      let ifSame = true
      list.forEach(e => {
        let re = list.filter(i => {
          return i.theme != e.theme
        })
        if (re.length > 0) {
          ifSame = true
        } else {
          ifSame = false
        }
      });
      return ifSame
    }
  }

 

posted @ 2023-02-17 13:17  程序员冒冒  阅读(8)  评论(0编辑  收藏  举报