el-tree 默认选中第一个且高亮显示

 node-key="id"  是关键

<el-tree
            :data="treeData"
            :props="defaultProps"
            @node-click="handleNodeClick"
            :highlight-current="true"
            :current-node-key="1"
            node-key="id"
            :default-checked-keys="[1]"
          >
</el-tree>
treeData: [
        {
        id:1,
        label: '生盘条导入质检查询', children: []
      },{
        id:2,
        label: '磷化盘条导入质检查询',children: []
      }, {
        id:3,
        label: '镀锌丝导入质检查询',children: []
      }, {
        id:4,
        label: '热处理丝导入质检查询',children: []
      }, {
        id:5,
        label: '成品导入质检查询',children: []
      }, {
        id:6,
        label: '导入出库列表',children: []
      }
      ],
      defaultProps: {
        // 如果你的树形结构含有子节点,可以定义子节点属性
        children: 'children',
        label: 'label',
        // 这里是设置节点的key
        key: 'id',
      },
<style scoped lang='scss'>
/* 改变被点击节点背景颜色,字体颜色 */
::v-deep .el-tree-node:focus > .el-tree-node__content {
  background-color: #6195F0 !important;
  color: #fff !important;
}

/* 节点失焦时的背景颜色 */
::v-deep .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  background-color: #6195F0 !important;
  color: #fff !important;
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值