下载 npm install --save @riophae/vue-treeselect
子组件treeSel.vue
<template>
<div id="app">
<treeselect
:multiple="true"
:options="treeData"
:disable-branch-nodes="true"
v-model="value"
search-nested
@select="treeOpen"
@deselect="desData"
style="width: 300px"
@input="treeInput"
:show-count="true"
:default-expand-level="2" //展开第二排
/>
</div>
</template>
<script>
// import the component
import Treeselect from "@riophae/vue-treeselect";
// import the styles
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import axios from "axios";
import TREESELECTURL from "../../../api/global.js";
export default {
props: {
labelTreeDataArr: {
typeof: Array,
default: () => [],
},
},
components: { Treeselect },
data() {
return {
value: null,
treeData: [],
arrTree: [],
};
},
methods: {
treeOpen(node) {
if (this.arrTree.includes(node.label)) {
return this.arrTree;
} else {
this.arrTree.push(node.label);
}