ant-design-vue/components/radio/demo/radioGroup-options.md

58 lines
1.4 KiB
Markdown
Raw Normal View History

2018-04-11 05:32:18 +00:00
<cn>
#### RadioGroup 组合 - 配置方式
通过配置 `options` 参数来渲染单选框。
</cn>
<us>
#### RadioGroup group - optional
Render radios by configuring `options`.
</us>
```html
2017-11-07 03:58:47 +00:00
<template>
2019-09-28 12:45:07 +00:00
<div>
<a-radio-group :options="plainOptions" @change="onChange1" :defaultValue="value1" />
<br />
<a-radio-group :options="options" @change="onChange2" v-model="value2" />
<br />
<a-radio-group :options="optionsWithDisabled" disabled @change="onChange3" v-model="value3" />
</div>
2017-11-07 03:58:47 +00:00
</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 = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Pear', value: 'Pear' },
{ label: 'Orange', value: 'Orange', disabled: false },
];
export default {
data() {
return {
plainOptions,
options,
optionsWithDisabled,
value1: 'Apple',
value2: 'Apple',
value3: 'Apple',
};
2017-11-07 03:58:47 +00:00
},
2019-09-28 12:45:07 +00:00
methods: {
onChange1(e) {
console.log('radio1 checked', e.target.value);
},
onChange2(e) {
console.log('radio2 checked', e.target.value);
},
onChange3(e) {
console.log('radio3 checked', e.target.value);
},
2017-11-07 03:58:47 +00:00
},
2019-09-28 12:45:07 +00:00
};
2017-11-07 03:58:47 +00:00
</script>
2018-04-11 05:32:18 +00:00
```