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.
ant-design-vue/components/auto-complete/demo/custom.vue

62 lines
1.2 KiB

<docs>
---
order: 2
title:
zh-CN: 自定义输入组件
en-US: Customize Input Component
---
## zh-CN
自定义输入组件
## en-US
Customize Input Component.
</docs>
<template>
<a-auto-complete
v-model:value="value"
:options="options"
style="width: 200px"
@search="handleSearch"
@select="onSelect"
>
<a-textarea
placeholder="input here"
class="custom"
style="height: 50px"
@keypress="handleKeyPress"
/>
</a-auto-complete>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const value = ref('');
const options = ref<{ value: string }[]>([]);
const onSelect = (value: string) => {
console.log('onSelect', value);
};
const handleSearch = (value: string) => {
options.value = !value
? []
: [{ value }, { value: value + value }, { value: value + value + value }];
};
const handleKeyPress = (ev: KeyboardEvent) => {
console.log('handleKeyPress', ev);
};
return {
value,
options,
onSelect,
handleSearch,
handleKeyPress,
};
},
});
</script>