elementui的el-tree第一次加載無法展開和選中的問題


問題現象

elmentui的el-tree數據加載問題,導致第一次加載選中當前節點和高亮當前節點沒有生效。

解決方案

默認展開節點的解決

在el-tree上面掛上data-change

<el-tree ref="orgTree" :options="orgTreeOptons" @data-change="handlechange" >
</el-tree>

使用nextTick進行設置

handlechange() {
  this.$nextTick(() => {
     this.$refs.orgTree.$refs.tree.setCurrentKey(this.treeNodeKey);
  });
},

默認高亮節點的解決

this.$refs.orgTree.$options.propsData.options.tree.defaultExpandedKeys = this.expandKey;


免責聲明!

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



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