ant-design-vue/examples/App.vue

88 lines
2.0 KiB
Vue
Raw Normal View History

2020-03-23 03:00:24 +00:00
<template>
2021-08-23 14:47:11 +00:00
<a-space direction="vertical" style="width: 100%">
<a-tree-select
v-model:value="value"
show-search
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="Please select"
allow-clear
tree-default-expand-all
:tree-data="treeData"
>
<template #suffixIcon><SmileOutlined /></template>
</a-tree-select>
<a-tree-select
v-model:value="value1"
show-search
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="Please select"
allow-clear
multiple
show-arrow
tree-default-expand-all
:tree-data="treeData"
>
<template #suffixIcon><SmileOutlined /></template>
</a-tree-select>
</a-space>
2020-03-23 03:00:24 +00:00
</template>
2021-08-17 14:03:49 +00:00
<script lang="ts">
2021-08-23 14:47:11 +00:00
import { SmileOutlined } from '@ant-design/icons-vue';
import { TreeSelectProps } from 'ant-design-vue';
2021-08-19 15:29:07 +00:00
import { defineComponent, ref, watch } from 'vue';
2021-08-22 08:59:13 +00:00
export default defineComponent({
2021-08-23 14:47:11 +00:00
components: {
SmileOutlined,
},
2021-08-22 08:59:13 +00:00
setup() {
2021-08-23 02:54:55 +00:00
const value = ref<string[]>([]);
2021-08-23 14:47:11 +00:00
const value1 = ref<string[]>([]);
const treeData = ref<TreeSelectProps['treeData']>([
{
title: 'parent 1',
value: 'parent 1',
children: [
{
title: 'parent 1-0',
value: 'parent 1-0',
children: [
{
title: 'my leaf',
value: 'leaf1',
},
{
title: 'your leaf',
value: 'leaf2',
},
],
},
{
title: 'parent 1-1',
value: 'parent 1-1',
},
],
},
]);
2021-08-22 08:59:13 +00:00
watch(value, () => {
2021-08-23 02:54:55 +00:00
console.log('select', value.value);
2021-08-22 08:59:13 +00:00
});
2021-08-23 02:54:55 +00:00
2021-08-17 14:03:49 +00:00
return {
2021-08-22 08:59:13 +00:00
value,
2021-08-23 14:47:11 +00:00
value1,
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>
<style>
.ant-select-dropdown {
/* top: 140px !important;
left: 50px !important; */
}
</style>