Detailed explanation of adding dotted lines to Vue element tree controls

Detailed explanation of adding dotted lines to Vue element tree controls

1. Achieve results

Rendering

2. Implementation Code

The addition of dotted lines to the tree control is mainly achieved by controlling CSS, and the indent number of the tree control can only be 0, so let class="mytree"

   <div class="mytree">
          <!--indent can only be 0-->
          <el-tree
              :data="tree_data"
              :props="defaultProps"
              @node-click="handleNodeClick"
              indent="0"
              :render-content="renderContent"
          ></el-tree>
   </div>

The css is set to the following code, using ::v-deep for style penetration

<style lang="scss" scoped>
::v-deep .mytree {
  .el-tree > .el-tree-node:after {
    border-top: none;
  }
  .el-tree-node {
    position: relative;
    padding-left: 16px;
  }
  //There is a gap between nodes, just hide the expand button, if you think the gap is okay, you can delete it.el-tree-node__expand-icon.is-leaf{
    display: none;
  }
  .el-tree-node__children {
    padding-left: 16px;
  }
  .el-tree-node :last-child:before {
    height: 38px;
  }
  .el-tree > .el-tree-node:before {
    border-left: none;
  }
  .el-tree > .el-tree-node:after {
    border-top: none;
  }
  .el-tree-node:before {
    content: "";
    left: -4px;
    position: absolute;
    right: auto;
    border-width: 1px;
  }
  .el-tree-node:after {
    content: "";
    left: -4px;
    position: absolute;
    right: auto;
    border-width: 1px;
  }
  .el-tree-node:before {
    border-left: 1px dashed #4386c6;
    bottom: 0px;
    height: 100%;
    top: -26px;
    width: 1px;
  }
  .el-tree-node:after {
    border-top: 1px dashed #4386c6;
    height: 20px;
    top: 12px;
    width: 24px;
  }
}
</style>

3. Other Implementations

Vue implements tree table through element tree control

Element-ui implements adding icons to tree control nodes

Summarize

This article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM!

You may also be interested in:
  • Vue implements tree table through element tree control
  • Vue Element-ui table realizes tree structure table
  • Vue component library ElementUI implements table loading tree data tutorial
  • Vue+element UI realizes tree table
  • Vue+Element UI tree control integrates drop-down function menu (tree + dropdown +input)
  • Vue Element-ui implements tree control node adding icon detailed explanation

<<:  How to hide a certain text in HTML?

>>:  Pure CSS to achieve the internal anchor point of the web page when the up and down offset code example

Recommend

How to restore a single database or table in MySQL and possible pitfalls

Preface: The most commonly used MySQL logical bac...

Docker View Process, Memory, and Cup Consumption

Docker view process, memory, cup consumption Star...

Sample code for seamless scrolling with flex layout

This article mainly introduces the sample code of...

Detailed explanation of Nginx process scheduling problem

Nginx uses a fixed number of multi-process models...

JavaScript event loop case study

Event loop in js Because JavaScript is single-thr...

Detailed explanation of Vue advanced construction properties

Table of contents 1. Directive custom directive 2...

Linux ssh server configuration code example

Use the following terminal command to install the...

Example of how to achieve ceiling effect using WeChat applet

Table of contents 1. Implementation 2. Problems 3...

Solution to 1449 and 1045 exceptions when connecting to MySQL

Solution to 1449 and 1045 exceptions when connect...

Perfect solution for vertical centering of form elements

Copy code The code is as follows: <!DOCTYPE ht...

What does mysql database do

MySQL is a relational database management system ...

Summary of common knowledge points required for MySQL

Table of contents Primary key constraint Unique p...

Enterprise-level installation tutorial using LAMP source code

Table of contents LAMP architecture 1.Lamp Introd...