ant-design-vue/examples/App.vue

66 lines
1.2 KiB
Vue
Raw Normal View History

2020-03-23 03:00:24 +00:00
<template>
2021-08-22 08:59:13 +00:00
<a-tree-select
v-model:value="value"
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
:tree-data="treeData"
placeholder="Please select"
tree-default-expand-all
2021-08-19 02:56:21 +00:00
>
2021-08-22 08:59:13 +00:00
<template #title1="{ key, value }">
<span v-if="key === '0-0-1'" style="color: #08c">Child Node1 {{ value }}</span>
</template>
</a-tree-select>
2020-03-23 03:00:24 +00:00
</template>
2021-08-17 14:03:49 +00:00
<script lang="ts">
2021-08-19 15:29:07 +00:00
import { defineComponent, ref, watch } from 'vue';
2021-08-22 08:59:13 +00:00
interface TreeDataItem {
value: string;
key: string;
title?: string;
slots?: Record<string, string>;
children?: TreeDataItem[];
}
const treeData: TreeDataItem[] = [
{
title: 'Node1',
value: '0-0',
key: '0-0',
children: [
2021-08-19 15:29:07 +00:00
{
2021-08-22 08:59:13 +00:00
value: '0-0-1',
key: '0-0-1',
slots: {
title: 'title1',
},
2021-08-19 15:29:07 +00:00
},
{
2021-08-22 08:59:13 +00:00
title: 'Child Node2',
value: '0-0-2',
key: '0-0-2',
2021-08-19 15:29:07 +00:00
},
2021-08-22 08:59:13 +00:00
],
},
{
title: 'Node2',
value: '0-1',
key: '0-1',
},
];
export default defineComponent({
setup() {
const value = ref<string>();
watch(value, () => {
console.log(value.value);
});
2021-08-17 14:03:49 +00:00
return {
2021-08-22 08:59:13 +00:00
value,
2021-08-19 15:29:07 +00:00
treeData,
2021-08-17 14:03:49 +00:00
};
2020-11-23 08:39:09 +00:00
},
});
2020-10-19 09:17:10 +00:00
</script>