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
In the web pages we make, if we want more people ...
Unlike other types of design, web design has been ...
1. Installation 1. Download MySQL Download addres...
1. Command Introduction The ipcs command is used ...
1. Create and run a container docker run -it --rm...
MySQL paging queries are usually implemented thro...
This article shares with you the installation and...
CSS: Copy code The code is as follows: html,body{ ...
The color presentation on a web page will be affec...
When configuring web.xml for tomcat, servlet is a...
This article uses examples to illustrate the pitf...
This article example shares the specific code for...
There are three types of MySQL stored procedure p...
This article shares the specific steps for config...
Overview In zabbix version 5.0 and above, a new f...