forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup.vue
65 lines (58 loc) · 1.39 KB
/
group.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<docs>
---
order: 4
title:
zh-CN: Checkbox 组
en-US: Checkbox group
---
## zh-CN
方便的从数组生成 checkbox
## en-US
Generate a group of checkboxes from an array
</docs>
<template>
<a-checkbox-group v-model:value="value1" name="checkboxgroup" :options="plainOptions" />
<br />
<br />
<a-checkbox-group v-model:value="value2" :options="plainOptions" />
<br />
<br />
<a-checkbox-group v-model:value="value3" :options="options" />
<br />
<br />
<a-checkbox-group v-model:value="value4" :options="optionsWithDisabled" disabled>
<template #label="{ label }">
<span style="color: red">{{ label }}</span>
</template>
</a-checkbox-group>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue';
const plainOptions = ['Apple', 'Pear', 'Orange'];
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Pear', value: 'Pear' },
{ label: 'Orange', value: 'Orange' },
];
const optionsWithDisabled = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Pear', value: 'Pear' },
{ label: 'Orange', value: 'Orange', disabled: false },
];
export default defineComponent({
setup() {
const state = reactive({
value1: [],
value2: ['Apple'],
value3: ['Pear'],
value4: ['Apple'],
});
return {
plainOptions,
options,
optionsWithDisabled,
...toRefs(state),
};
},
});
</script>