vue el-tree添加层级指示线

本文介绍了如何在Vue中使用el-tree组件添加层级指示线。通过设置`indent`属性和自定义样式,实现了节点的缩进调整和层级连接线的绘制。详细步骤包括在div中添加el-tree组件,设置必要的属性,以及编写CSS样式来完成指示线的显示。最后展示了添加层级指示线后的效果。
部署运行你感兴趣的模型镜像

1.div中放个tree
注意设置:  :indent="0",否则节点会出现较大缩进

 <div ref="treeDiv" class="tree-container">
    <el-tree id="tree" class="tree" @node-click="treeNodeClick"
             :data="data" :indent="0" node-key="id" default-expand-all :expand-on-click-node="false" lazy>
    </el-tree>
  </div>
2.设置样式
注意:tree-container是tree父容器的class name,通过此方法设置tree的根节点样式

.tree-container /deep/ .el-tree > .el-tree-node:after {
  border-top: none;
}
<style scoped>
 
  .tree /deep/ .el-tree-node {
    position: relative;
    padding-left: 16px;
  }
 
  .tree /deep/ .el-tree-node__children {
    padding-left: 16px;
  }
 
  .tree /deep/ .el-tree-node :last-child:before {
    height: 38px;
  }
 
  .tree /deep/ .el-tree > .el-tree-node:before {
    border-left: none;
  }
 
  .tree-container /deep/ .el-tree > .el-tree-node:after {
    border-top: none;
  }
 
  .tree /deep/ .el-tree-node:before {
    content: "";
    left: -4px;
    position: absolute;
    right: auto;
    border-width: 1px;
  }
 
  .tree /deep/ .el-tree-node:after {
    content: "";
    left: -4px;
    position: absolute;
    right: auto;
    border-width: 1px;
  }
 
  .tree /deep/ .el-tree-node:before {
    border-left: 1px dashed #4386c6;
    bottom: 0px;
    height: 100%;
    top: -26px;
    width: 1px;
  }
 
  .tree /deep/ .el-tree-node:after {
    border-top: 1px dashed #4386c6;
    height: 20px;
    top: 12px;
    width: 24px;
  }
 
.tree-container { //树的parent,样式自定
  }
</style>
3.效果图

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.9

TensorFlow-v2.9

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值