element-ui的表格树使用(完整版)

表格树,element-tree-grid需要单独下载并再配合elementUi里el-table使用。
步骤:1、npm install element-tree-grid --save(下载element-tree-grid)
步骤:2、在main.js中引用import ElTreeGrid from 'element-tree-grid'     Vue.component(ElTreeGrid.name,ElTreeGrid) 

 

效果截图           

QQ截图20200708152341.png

代码实现            

 THIS IS TITLE                           

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!-- 菜单树 -->
<template>
  <div class="menus-tree">
  <el-table :data="model.menus" border max-height="400" ref="table">
      <el-table-column prop="id" label="id" type="selection" fixed></el-table-column>
      <el-table-tree-column fixed :expand-all="!!1" :remote="remote" file-icon="icon icon-file"
          folder-icon="icon icon-folder" prop="label" label="title" width="320" class-name="123"
          header-align="center">
      </el-table-tree-column>
      <el-table-column prop="description" label="Description" :show-overflow-tooltip="true" width="180">
      </el-table-column>
  </el-table>
  </div>
</template>
<script>
    var flatTree = [{
        "id": 1,
        "label": "System",
        "parent_id": null,
        "url": null,
        "depth": 0,
        "child_num": 3,
        "description": "System Manager"
    }, {
        "id": 2,
        "label": "base",
        "parent_id": 1,
        "depth": 1,
        "child_num": 5,
        "description": "Base Manager",
    }, {
        "id": 3,
        "label": "Menus",
        "parent_id": 2,
        "depth": 2,
        "child_num": 0,
        "description": "menu manager",
    }, {
        "id": 4,
        "label": "Roles",
        "parent_id": 2,
        "depth": 2,
        "child_num": 0,
        "description": "Role Manager",
    }, {
        "id": 5,
        "label": "Users",
        "parent_id": 2,
        "depth": 2,
        "child_num": 0,
        "description": "User Manager",
    }, {
        "id": 6,
        "label": "Customs",
        "parent_id": null,
        "url": null,
        "depth": 0,
        "child_num": 2,
        "description": "Custom Manager",
    }, {
        "id": 7,
        "label": "CustomList",
        "parent_id": 6,
        "depth": 1,
        "child_num": 0,
        "description": "CustomList",
    }, {
        "id": 8,
        "label": "Templates",
        "parent_id": null,
        "url": null,
        "depth": 0,
        "child_num": 1,
        "description": "Template Manager",
    }, {
        "id": 9,
        "label": "TemplateList",
        "parent_id": 8,
        "depth": 1,
        "child_num": 0,
        "description": "Template Manager",
    }, {
        "id": 10,
        "label": "Bussiness",
        "parent_id": null,
        "url": null,
        "depth": 0,
        "child_num": 2,
        "description": "Bussiness Manager",
    },
    {
        "id": 11,
        "label": "BussinessList",
        "parent_id": 10,
        "url": null,
        "depth": 1,
        "child_num": 2,
        "description": "BussinessList",
        "children": []
    }, {
        "id": 12,
        "label": "Currencies",
        "parent_id": 11,
        "depth": 2,
        "child_num": 0,
        "description": "Currencies",
    }, {
        "id": 13,
        "label": "Dealtypes",
        "parent_id": 11,
        "depth": 2,
        "child_num": 0,
        "description": "Dealtypes",
    }, {
        "id": 14,
        "label": "Products",
        "parent_id": 10,
        "url": null,
        "depth": 1,
        "child_num": 2,
        "description": "Products"
    }, {
        "id": 15,
        "label": "ProductTypes",
        "parent_id": 14,
        "depth": 2,
        "child_num": 0,
        "description": "ProductTypes",
    }, {
        "id": 16,
        "label": "ProductList",
        "parent_id": 14,
        "depth": 2,
        "child_num": 0,
        "description": "ProductList",
    }]
      export default {
        data() {
          return {
             model: {
                 menus: flatTree.filter(f => f['parent_id'] == null)
             }
             
          }
        },
        methods: {
        remote(row, callback) {
            callback(flatTree.filter(f => f['parent_id'] == row['id']))
        },
        formatter(row, column) {
            return ' ---  ' + row.label;
        },
        cl() {
            this.$refs.table.$emit("clearTreeCloumn")
        }
        }
      }
    </script>
  <style type="text/css">
        
        .icon-file {
            padding-right: 7px;
            padding-left: 18px
        }
 
        .icon-folder,
        .icon-folder-open {
            padding-left: 7px;
            padding-right: 7px
        }
    </style>

  


posted @   落日知暮  阅读(4901)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
作者:boyzi007 出处:http://www.cnblogs.com/boyzi/ QQ:470797533 QQ交流群:364307742 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
点击右上角即可分享
微信分享提示