<template>
<view class="test">
<TreeSelect color="#36D6B6" :left-items="leftItems" :right-items="rightItems" @click-nav="clickNav">
<!--自定义左侧显示字段名-->
<template v-slot:left-text="slotProps">
{{ slotProps.value.text }}
</template>
<!--自定义右侧模板-->
<template v-slot:right="slotProps">
<view class="card">{{ slotProps.value.text }}</view>
</template>
</TreeSelect>
</view>
</template>
<script setup lang="ts">
import {reactive} from "vue"
const leftItems = reactive([
{
text : '左侧选项一',
},
{
text : '左侧选项二',
},
{
text : '左侧选项三',
disabled : true
},
])
const rightItems = reactive([
{
text : '右侧选项一',
},
{
text : '右侧选项二',
},
{
text : '右侧选项三',
},
{
text : '右侧选项四',
},
{
text : '右侧选项五',
},
{
text : '右侧选项六',
},
])
const clickNav = (value : any, index : number) => {
console.log(value)
console.log(index)
}
</script>
<style lang="scss" scoped>
.card {
width: 100%;
height: vw(100);
border: vw(2) solid #e1e1e1;
border-radius: vw(10);
margin: 0 0 vw(20) 0;
}
</style>