zoukankan      html  css  js  c++  java
  • elementui tree控件 设置默认选中并高亮第一行

     注意:一定要写上this.$nextTick   否则不生效

          <el-tree
                  ref="treeRef"
                  :highlight-current="true"
                  default-expand-all
                  :data="architectureData"
                  node-key="id"
                  :current-node-key="currentNodekey"
                  :props="defaultProps"
                  @node-click="handleNodeClick"
                ></el-tree>



    currentNodekey: "", //默认选中的节点树 async treeByDept() { await treeByDept({}).then((res) => { this.architectureData = res.data; if (this.architectureData.length > 0) { this.currentNodekey = this.architectureData[0].id; this.$nextTick(() => { this.$refs.treeRef.setCurrentKey(this.currentNodekey); //一定要加这个选中了否则样式没有出来 }); } }); },



    /* 点击树结构项的选中颜色 */
    .el-tree--highlight-current .is-current.el-tree-node > .el-tree-node__content {
      background-color: #99ccff !important;
    }
  • 相关阅读:
    apache安装 解决无services
    需要看的书
    rbac
    IDocHostShowUI
    Eclipse快捷键大全
    Linux中vi显示中文乱码的问题
    如何编译安装Go语言
    ubuntu11.04 下LAMP 开发环境配置
    网络内核sk_buff结构体
    查看所有表名,查询结果加上字符
  • 原文地址:https://www.cnblogs.com/web-aqin/p/14926651.html
Copyright © 2011-2022 走看看