当前位置:   article > 正文

vue el-tree添加层级指示线_el-tree加虚线

el-tree加虚线

1.div中放个tree

注意设置:  :indent="0",否则节点会出现较大缩进

  1. <div ref="treeDiv" class="tree-container">
  2. <el-tree id="tree" class="tree" @node-click="treeNodeClick"
  3. :indent="0"
  4. :props="defaultProps"
  5. :load="queryTreeNode"
  6. node-key="uniqueidentification" ref="tree" lazy>
  7. </el-tree>
  8. </div>

2.设置样式

注意:tree-container是tree父容器的class name,通过此方法设置tree的根节点样式

.tree-container /deep/ .el-tree > .el-tree-node:after {
  border-top: none;
}
  1. <style scoped>
  2. .tree /deep/ .el-tree-node {
  3. position: relative;
  4. padding-left: 16px;
  5. }
  6. .tree /deep/ .el-tree-node__children {
  7. padding-left: 16px;
  8. }
  9. .tree /deep/ .el-tree-node :last-child:before {
  10. height: 38px;
  11. }
  12. .tree /deep/ .el-tree > .el-tree-node:before {
  13. border-left: none;
  14. }
  15. .tree-container /deep/ .el-tree > .el-tree-node:after {
  16. border-top: none;
  17. }
  18. .tree /deep/ .el-tree-node:before {
  19. content: "";
  20. left: -4px;
  21. position: absolute;
  22. right: auto;
  23. border-width: 1px;
  24. }
  25. .tree /deep/ .el-tree-node:after {
  26. content: "";
  27. left: -4px;
  28. position: absolute;
  29. right: auto;
  30. border-width: 1px;
  31. }
  32. .tree /deep/ .el-tree-node:before {
  33. border-left: 1px dashed #4386c6;
  34. bottom: 0px;
  35. height: 100%;
  36. top: -26px;
  37. width: 1px;
  38. }
  39. .tree /deep/ .el-tree-node:after {
  40. border-top: 1px dashed #4386c6;
  41. height: 20px;
  42. top: 12px;
  43. width: 24px;
  44. }
  45. .tree-container { //树的parent,样式自定
  46. }
  47. </style>

3.效果图

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/322380
推荐阅读