<template>
  <div class="JKWTree-container">

    <div class="JKWTree-tree">
      <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
    </div>

  </div>
</template>
<script setup>
import { toRaw,ref } from 'vue';
// import axios from "../utils/request.js"//引入封装的axios

/* 配置数据字段的适配名 */
const defaultProps = {
  label: 'label',
  children: 'children',
}


const treeData=ref([{
  label: '一级 1',
  children: [{
    label: '二级 1-1',
    children: [{
      label: '三级 1-1-1'
    }]
  }]
}, {
  label: '一级 2',
  children: [{
    label: '二级 2-1',
    children: [{
      label: '三级 2-1-1'
    }]
  }, {
    label: '二级 2-2',
    children: [{
      label: '三级 2-2-1'
    }]
  }]
}, {
  label: '一级 3',
  children: [{
    label: '二级 3-1',
    children: [{
      label: '三级 3-1-1'
    }]
  }, {
    label: '二级 3-2',
    children: [{
      label: '三级 3-2-1'
    }]
  }]
}])


//当前节点的nodeId
let nodeIdForNow=ref(0)
/**节点点击节点事件 */
const handleNodeClick = (node,check) => {
  //存放当前节点的nodeId
  console.log(node,check);

}

</script>
<style scoped>
.JKWTree-container {
  display: flex;
}

.JKWTree-tree {
  width: 300px;
  background-color: #fff;
  padding: 10px;
  margin-right: 20px;
}

.JKWTree-tree h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0;
}

.JKWTree-content {
  flex: 1;
}
</style>