element-ui tree全部展开和全部折叠

     node-key="id"很重要

  






unFoldAll () {
      //  全部展开

      let self = this;
// 将没有转换成树的原数据
      let treeList = this.sourceData;
      for (let i = 0; i < treeList.length; i++) {
// 将没有转换成树的原数据设置key为... 的展开
        self.$refs.selectTree.store.nodesMap[treeList[i].id].expanded = true
      }
    },
    collapseAll () {
      //  全部折叠
      let self = this;
      let treeList = this.sourceData;
      for (let i = 0; i < treeList.length; i++) {
        self.$refs.selectTree.store.nodesMap[treeList[i].id].expanded = false
      }
    },

 

你可能感兴趣的:(前端)