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;
    }
  • 相关阅读:
    获取URL中参数
    Javascript this指针
    10分钟了解C#中的协变和逆变
    BCB写的简单的EXCEL合并
    Codeforces Round #316 (Div. 2) D
    Codeforces Round #316 (Div. 2) E
    fzu1873 Coin Puzzle
    hdu 3629 Convex
    几何统计 ACM ICPC
    hdu 5135 Little Zu Chongzhi's Triangles
  • 原文地址:https://www.cnblogs.com/web-aqin/p/14926651.html
Copyright © 2011-2022 走看看