目录
备注:采坑多次,终于爬出来了,特地记录下。
1.引入js,在main.js引入js
//201905引入外部组件ztree
//import $ from "jquery"
import "../plugins/ztree/js/jquery-1.4.4.min.js"
import "../plugins/ztree/js/jquery.ztree.core.min.js"
import "../plugins/ztree/js/jquery.ztree.excheck.min.js"
2.写一个demo,zTree.vue
<template>
<div class="tree-box" >
<ul id="treeDemo" class="ztree" ></ul>
</div>
</template>
<script>
export default {
name: 'zTree',
components:{
},
data (){
return{
setting:{
data: {
simpleData: {
enable: true
}
},
check: {
enable: true,
nocheckInherit: false ,
chkboxType: { "Y": "p", "N": "s" }
},
callback: {
beforeClick: this.beforeClick,
onClick: this.zTreeOnClick,
onCheck: this.zTreeOnCheck,
}
},
/*zNodes:[
{ name:"父节点1 - 展开", open:true,
children: [
{ name:"父节点11 - 折叠",
children: [
{ name:"叶子节点111"},
{ name:"叶子节点112"},
{ name:"叶子节点113"},
{ name:"叶子节点114"}
]},
{ name:"父节点12 - 折叠",
children: [
{ name:"叶子节点121"},
{ name:"叶子节点122"},
{ name:"叶子节点123"},
{ name:"叶子节点124"}
]},
{ name:"父节点13 - 没有子节点", isParent:true}
]},
{ name:"父节点2 - 折叠",
children: [
{ name:"父节点21 - 展开", open:true,
children: [
{ name:"叶子节点211"},
{ name:"叶子节点212"},
{ name:"叶子节点213"},
{ name:"叶子节点214"}
]},
{ name:"父节点22 - 折叠",
children: [