2018-03-09 05:26:34 +00:00
|
|
|
<cn>
|
|
|
|
#### Checkbox组
|
|
|
|
方便的从数组生成checkbox
|
|
|
|
</cn>
|
|
|
|
|
|
|
|
<us>
|
|
|
|
#### Checkbox group
|
|
|
|
Generate a group of checkboxes from an array
|
|
|
|
</us>
|
|
|
|
|
2019-10-09 10:32:23 +00:00
|
|
|
```tpl
|
2018-03-09 05:26:34 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<a-checkbox-group :options="plainOptions" v-model="value" @change="onChange" />
|
|
|
|
<br />
|
|
|
|
<a-checkbox-group :options="plainOptions" :defaultValue="['Apple']" @change="onChange" />
|
|
|
|
<br />
|
|
|
|
<a-checkbox-group :options="options" :value="['Pear']" @change="onChange" />
|
|
|
|
<br />
|
2019-09-28 12:45:07 +00:00
|
|
|
<a-checkbox-group
|
|
|
|
:options="optionsWithDisabled"
|
|
|
|
disabled
|
|
|
|
:defaultValue="['Apple']"
|
|
|
|
@change="onChange"
|
|
|
|
>
|
2019-01-02 12:21:01 +00:00
|
|
|
<span style="color: red" slot="label" slot-scope="{value}">{{value}}</span>
|
|
|
|
</a-checkbox-group>
|
2018-03-09 05:26:34 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-09-28 12:45:07 +00:00
|
|
|
const plainOptions = ['Apple', 'Pear', 'Orange'];
|
|
|
|
const options = [
|
|
|
|
{ label: 'Apple', value: 'Apple' },
|
|
|
|
{ label: 'Pear', value: 'Pear' },
|
|
|
|
{ label: 'Orange', value: 'Orange' },
|
|
|
|
];
|
|
|
|
const optionsWithDisabled = [
|
|
|
|
{ value: 'Apple' },
|
|
|
|
{ label: 'Pear', value: 'Pear' },
|
|
|
|
{ label: 'Orange', value: 'Orange', disabled: false },
|
|
|
|
];
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
plainOptions,
|
|
|
|
options,
|
|
|
|
optionsWithDisabled,
|
|
|
|
value: [],
|
|
|
|
};
|
2018-03-09 05:26:34 +00:00
|
|
|
},
|
2019-09-28 12:45:07 +00:00
|
|
|
methods: {
|
|
|
|
onChange(checkedValues) {
|
|
|
|
console.log('checked = ', checkedValues);
|
|
|
|
console.log('value = ', this.value);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2018-03-09 05:26:34 +00:00
|
|
|
</script>
|
|
|
|
```
|