npm# use npm npm install vue-tree-color Install the loadernpm install --save-dev less less-loader Import Pluginsimport Vue from 'vue' import Vue2OrgTree from 'vue-tree-color' Vue.use(Vue2OrgTree) startBecause the component has been installed, you can use it directly. In the Vue page, directly use the component tag to dynamically bind the data (the data can be recursive data) <vue2-org-tree :data="data"/> Data is placed in the page In the data data, id is a different ID for each element, label is name, and children is its own subset data. ArrangementJust now we saw the default arrangement, but there is also a horizontal arrangement. # Just add horizontal <vue2-org-tree :data="data" :horizontal="true" /> The effect is as follows Folding displayAdd a property collapsable <vue2-org-tree :data="data" :horizontal="true" collapsable /> How to expand it? You need to add a component with its own method on-expand <vue2-org-tree :data="data" :horizontal="true" collapsable @on-expand="onExpand" /> js part methods: { collapse(list) { var _this = this list.forEach(function(child) { if (child.expand) { child.expand = false } child.children && _this.collapse(child.children) }) }, onExpand(e, data) { if ('expand' in data) { data.expand = !data.expand if (!data.expand && data.children) { this.collapse(data.children) } } else { this.$set(data, 'expand', true) } } } The effect is as follows Click on the nodeAdd a method on-node-click <vue2-org-tree :data="data" :horizontal="true" collapsable @on-expand="onExpand" @on-node-click="onNodeHandle" /> js onNodeHandle(e, data) { // e is the node data console.log(e) // data is the data rendered on the node console.log(data) }, Printing Results Other FeaturesThe component also provides other functions, probably the more commonly used ones are setting node color, moving in and out, etc. I paste the github address in, and those who are interested can learn about it themselves Click on the link below to view more functions of the component https://github.com/hukaibaihu/vue-org-tree#readme This is the end of this article about the detailed explanation of the case of implementing the organizational structure chart of Vue's vue-tree-color component. For more relevant content about implementing the organizational structure chart of Vue's vue-tree-color component, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Brief analysis of mysql scheduled backup tasks
>>: Linux cut command explained
After the server where Docker is located has been...
Docker basic instructions: Update Packages yum -y...
Table of contents 1. Deconstruction Tips 2. Digit...
Table of contents How to rename MySQL database Th...
<br />Previous Web Design Tutorial: Web Desi...
Table of contents Typical waterfall website Water...
Install FFmpeg flac eric@ray:~$ sudo apt install ...
I won't go into details about how important b...
Preface As a heavy user of front-end frameworks, ...
Table of contents Install Configuration Common Mi...
Linux task management - background running and te...
There are two types of Linux system time. (1) Cal...
The implementation method is divided into three s...
Table of contents Single condition single data fi...
Preface Not long ago, I combined browser-sync+gul...