货无忧
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
785 B

<template>
<view>
<MyTree :tree-data="treeData" @node-click="nodeClick" :activeId="activeId"></MyTree>
</view>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const treeData = [
{ id: 1, name: '一级1' },
{
id: 2,
name: '一级2',
children: [
{ id: 3, name: '二级2-1' },
{ id: 4, name: '二级2-2' }
]
},
{
id: 5,
name: '一级3',
children: [
{
id: 6,
name: '二级3-1',
children: [
{ id: 7, name: '三级3-1-1' },
{ id: 8, name: '三级3-1-2' }
]
},
{ id: 9, name: '二级3-2' },
{ id: 10, name: '二级3-3' }
]
}
]
const activeId = ref(0)
const nodeClick = (val) => {
console.log(val)
activeId.value = val.id
}
</script>
<style lang="scss" scoped></style>