一路繁花似锦绣前程
失败的越多,成功才越有价值

导航

 
<template>
  <el-tree :data="data" default-expand-all :props="defaultProps" @node-click="handleNodeClick" />
</template>

<script>
export default {
  name: 'Dashboard',
  data() {
    return {
      data: [
        {
          label: '一级 1',
          children: [{
            label: '二级 1-1',
            children: [{
              label: '三级 1-1-1'
            }]
          }]
        }, {
          label: '一级 2',
          children: [{
            label: '二级 2-1',
            children: [{
              label: '三级 2-1-1'
            }]
          }, {
            label: '二级 2-2',
            children: [{
              label: '三级 2-2-1'
            }]
          }]
        }, {
          label: '一级 3',
          children: [{
            label: '二级 3-1',
            children: [{
              label: '三级 3-1-1'
            }]
          }, {
            label: '二级 3-2',
            children: [{
              label: '三级 3-2-1'
            }, {
              label: '三级 3-2-2'
            }]
          }]
        }],
      defaultProps: {
        children: 'children',
        label: 'label'
      }
    }
  },
  methods: {
    handleNodeClick(data) {
      console.log(data)
    }
  }
}
</script>

<style lang="scss" scoped>
  .el-tree ::v-deep {
    .el-tree-node__content {
      position: relative;
    }

    .el-tree-node:last-child > .el-tree-node__content::before {
      content: "";
      width: 1px;
      height: 10000px;
      background-color: green;
      position: absolute;
      margin-left: -9px;
      bottom: 13px;
    }

    .el-tree-node__children .el-tree-node__content::after {
      content: "";
      width: 9px;
      height: 1px;
      background-color: red;
      position: absolute;
      margin-left: -9px;
    }

    .el-tree-node__content > .el-tree-node__expand-icon {
      padding: 6px 3px;
    }
  }
</style>
<!-- <style lang="scss" scoped>
  /* 方式二的思路 */
  .el-tree ::v-deep {
    .el-tree-node__children {
      padding-left: 24px;

      .el-tree-node::before {
        height: 100%;
        top: -26px;
      }

      .el-tree-node:last-child::before {
        height: 38px;
      }
    }
  }
</style> -->
posted on 2022-04-23 01:41  一路繁花似锦绣前程  阅读(2401)  评论(0编辑  收藏  举报