element -tree组件默认高亮选中节点

默认高亮选中树节点

  1. 需要用到方法 – setCurrentKey
  2. 必须设置属性 – node-key

在这里插入图片描述
code


       // 自定义树节点的 icon
          
          
          {{node.label}}
    

// 获取仓库树
 getTree(){
     getwarehousetree().then(response =>{
         if(response && response.code == 200){
             let arr = []
             this.warehouseTree = response.rows || []
             this.getLeafKeys(this.warehouseTree[0],arr)
             this.warehouseForm.ids = arr
             this.onSearch()
             this.$nextTick(()=>{  // 默认高亮选中节点
                 this.$refs.tree.setCurrentKey(this.warehouseTree[0].id)
             })
         }
     })
 },

你可能感兴趣的:(vue-个人杂记)