ant-design-vue/components/select/demo/basic.vue
Cherry7 9be58078d2
Refactor(demo): change options to composition api (#6499)
* feat(demo): A-B

* feat(demo): update B-checkbox

* feat(demo): update CheckBox -DatePicker

* feat(demo): update DatePicker - Form

* feat(demo): update Form - List

* feat(demo): update  List-pagination

* feat(demo): update  List - skeleton

* feat(demo): update  skeleton - switch

* feat(demo): update  skeleton - switch

* feat(demo): update   switch - upload

* feat(demo): update  watermark

* fix(demo): del hashId
2023-04-28 14:08:21 +08:00

100 lines
2.1 KiB
Vue

<docs>
---
order: 0
title:
zh-CN: 基本使用
en-US: Basic Usage
---
## zh-CN
基本使用
## en-US
Basic Usage
</docs>
<template>
<h2>use a-select-option</h2>
<a-space>
<a-select
ref="select"
v-model:value="value1"
style="width: 120px"
@focus="focus"
@change="handleChange"
>
<a-select-option value="jack">Jack</a-select-option>
<a-select-option value="lucy">Lucy</a-select-option>
<a-select-option value="disabled" disabled>Disabled</a-select-option>
<a-select-option value="Yiminghe">yiminghe</a-select-option>
</a-select>
<a-select v-model:value="value2" style="width: 120px" disabled>
<a-select-option value="lucy">Lucy</a-select-option>
</a-select>
<a-select v-model:value="value3" style="width: 120px" loading>
<a-select-option value="lucy">Lucy</a-select-option>
</a-select>
</a-space>
<h2 style="margin-top: 10px">use options (recommend)</h2>
<a-space>
<a-select
ref="select"
v-model:value="value1"
style="width: 120px"
:options="options1"
@focus="focus"
@change="handleChange"
></a-select>
<a-select v-model:value="value2" style="width: 120px" disabled :options="options2"></a-select>
<a-select v-model:value="value3" style="width: 120px" loading :options="options3"></a-select>
</a-space>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import type { SelectProps } from 'ant-design-vue';
const value1 = ref('lucy');
const value2 = ref('lucy');
const value3 = ref('lucy');
const options1 = ref<SelectProps['options']>([
{
value: 'jack',
label: 'Jack',
},
{
value: 'lucy',
label: 'Lucy',
},
{
value: 'disabled',
label: 'Disabled',
disabled: true,
},
{
value: 'yiminghe',
label: 'Yiminghe',
},
]);
const options2 = ref<SelectProps['options']>([
{
value: 'lucy',
label: 'Lucy',
},
]);
const options3 = ref<SelectProps['options']>([
{
value: 'lucy',
label: 'Lucy',
},
]);
const focus = () => {
console.log('focus');
};
const handleChange = (value: string) => {
console.log(`selected ${value}`);
};
</script>