动态设置elementui 的el-tree的层级只显示2个层级

需要设置

node-key和default-expanded-keys

官方链接:

Element - The world's most popular Vue UI framework

关键代码:

        <div class="head-container">
          <el-tree
            :data="deptOptions"
            :props="defaultProps"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            ref="tree"
            node-key="id"
            :default-expanded-keys="nodeKey"
            @node-click="handleNodeClick"
          />
        </div>

data:

nodeKey:[],
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data
        // console.log('this.deptOptions')
        // console.log(this.deptOptions)
        // console.log(this.deptOptions[0])
        this.nodeKey.push(this.deptOptions[0].id)
      })
    },

参考:

Element - The world's most popular Vue UI framework

https://segmentfault.com/q/1010000039058699?utm_source=tag-newest

vue el-tree:默认展开第几级节点 - Jaye118 - 博客园

另一个 类似的:

el-table里的层级:

https://segmentfault.com/q/1010000008981772

Element - The world's most popular Vue UI framework


版权声明:本文为qq_22182989原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。