In Vue, use the element tree control to achieve the effect of tree table Use indentation to achieve a tree-like effect Implementation effect diagramInstall Dependencies Element official website Custom tree controls Analyze the distribution of controls in the diagram. Each parameter has a fixed The code mainly uses the <template> <div class="mytree"> <el-tree :data="tree_data" :props="defaultProps" @node-click="handleNodeClick" indent="0" :render-content="renderContent" ></el-tree> </div> </template> <script lang="ts"> import { defineComponent, ref } from 'vue' export default defineComponent({ components: {}, data() { return { tree_data: [ { // type:1, label: 'notice-id1', children: [ { label: ['Satellite name code', 'ZOHREH-2'], }, { label: ['Organization', 'IRN'], }, { label: ['Frequency range', '10950-1450'], }, { label: '[upper row] beam name', children: [ { label:['name','RS49'], }, { label:['freq_min','10950'], }, { label:['freq_max','14500'], }, { label:[]'group('+'3'+')',''] children:[ { label:['10600361','10950','11200','0'] }, { label:['10600361','10950','11200','0'] }, { label:['10600361','10950','11200','0'] } ] } ] }, ], }, ], defaultProps: { children: 'children', label: 'label', }, } }, method:{ // Custom tree control function node represents each node renderContent(h,{node,data,store}){ //div represents a row of the tree control, and div contains three span tags // Determine the number of label arrays of the node and select the class through ternary operation // Set the class to control the alignment of the tree control return h('div',[ h('span', {class:node.label.length === 2 ? 'nodeStyle':'groupStyle'},node.label[0]), h('span', {class:'groupStyle'},node.label[1]), h('span',{class:node.label.length === 2 ? 'nodeStyle':'groupStyle'},node.label.length === 2 ? '':node.label[2]) ]); }, } }) </script> <style lang="scss" scoped> .nodeStyle{ width:110px; display:inline-block; text-align:left; } .groupStyle{ width:150px; display:inline-block; text-align:left; } </style> Other Implementations Add a dotted line to the element tree control Element-ui implements adding icons to tree control nodes SummarizeThe tree table is mainly implemented by combining the custom function renderContent of the element's tree control with CSS 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:
|
<<: Display and hide HTML elements through display or visibility
>>: Solution to CSS anchor positioning being blocked by the top fixed navigation bar
1. Introduction Responsive Web design allows a we...
1.1 Copy the nginx installation package and insta...
Prerequisite: Percona 5.6 version, transaction is...
1. Install the cross-system file transfer tool un...
"What's wrong?" Unless you are accus...
Like means "like" in Chinese, but when ...
Recently, when upgrading the Zabbix database from...
1. Introduction The difference between row locks ...
Simply put, delayed replication is to set a fixed...
Table of contents 1. Process 2. Core Architecture...
Ubuntu install jdk: [link] Install Eclipse on Ubu...
Preface If CSS is the basic skill of front-end de...
This article shares the installation and configur...
Table of contents Written in front Two-way encryp...
We all know that the commonly used positioning me...