vue中el-tree中,如何設置某個節點選中


關鍵點:

<el-tree ref="eltree"
        :data="treeData"
        highlight-current
        node-key="idno"
        :props="defaultProps"
     v-if="thevalue"> </el-tree>

 

當頁面打開時,根據入參定位到某個節點時,使用如下方法設置即可;

比如node中某個idno=123;定位到該值節點時;

第一種方式:

this.$nextTick(() => {

  this.$refs.tree.setCurrentKey(123)

})

是不是很簡單;

第二種方式:

在mounted()函數中,設置thevalue=123;同樣可以定位到該節點;

 


免責聲明!

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



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