elementui 樹控件默認隱藏第三級菜單


<!-- 必須屬性:  default-expanded-keys  node-key 
default-expanded-keys 設置默認展開的數組
-->
<el-tree :default-expanded-keys='idArr' node-key="id" :data="orgtree" :props="defaultProps" @node-click="handleNodeClick" highlight-current ></el-tree>
data() {
    return {
      defaultProps: {
        children: "children",
        label: this.labelFn
      },
      orgtree: [],
      idArr:[]
    };
methods:{
getOrgTree() {
      get("地址").then(res => {
        this.orgtree = res.data.data;
     //將第一級的id push進數組
        this.orgtree.forEach(item=>{
            this.idArr.push(item.id)
        })
    //將第二級的id push進數組
        if(this.orgtree[0].children.length>0){
          this.orgtree[0].children.forEach(item=>{
            this.idArr.push(item.id)
        })
        }
      });
    },
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM