mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-04 13:08:48 +08:00
9be58078d2
* 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
81 lines
1.6 KiB
Vue
81 lines
1.6 KiB
Vue
<docs>
|
|
---
|
|
order: 7
|
|
title:
|
|
zh-CN: 分组
|
|
en-US: Option Group
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
用 `OptGroup` 或 `options.options` 进行选项分组。
|
|
|
|
## en-US
|
|
|
|
Using `OptGroup` or `options.options` to group the options.
|
|
|
|
</docs>
|
|
|
|
<template>
|
|
<a-space>
|
|
<a-select v-model:value="value" style="width: 200px" @change="handleChange">
|
|
<a-select-opt-group>
|
|
<template #label>
|
|
<span>
|
|
<user-outlined />
|
|
Manager
|
|
</span>
|
|
</template>
|
|
<a-select-option value="jack">Jack</a-select-option>
|
|
<a-select-option value="lucy">Lucy</a-select-option>
|
|
</a-select-opt-group>
|
|
<a-select-opt-group label="Engineer">
|
|
<a-select-option value="Yiminghe">yiminghe</a-select-option>
|
|
<a-select-option value="Yiminghe1">yiminghe1</a-select-option>
|
|
</a-select-opt-group>
|
|
</a-select>
|
|
<a-select
|
|
v-model:value="value"
|
|
:options="options"
|
|
style="width: 200px"
|
|
@change="handleChange"
|
|
></a-select>
|
|
</a-space>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { ref } from 'vue';
|
|
import { UserOutlined } from '@ant-design/icons-vue';
|
|
import type { SelectProps } from 'ant-design-vue';
|
|
|
|
const handleChange = (value: string) => {
|
|
console.log(`selected ${value}`);
|
|
};
|
|
|
|
const options = ref<SelectProps['options']>([
|
|
{
|
|
label: 'Manager',
|
|
options: [
|
|
{
|
|
value: 'jack',
|
|
label: 'Jack',
|
|
},
|
|
{
|
|
value: 'lucy',
|
|
label: 'Lucy',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: 'Engineer',
|
|
options: [
|
|
{
|
|
value: 'yiminghe',
|
|
label: 'Yiminghe',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
|
|
const value = ref(['lucy']);
|
|
</script>
|