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

58 lines
1.3 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>
<div>
2018-04-11 05:32:18 +00:00
<a-radio-group :options="plainOptions" @change="onChange1" :defaultValue="value1" />
2017-11-07 03:58:47 +00:00
<br />
2018-04-11 05:32:18 +00:00
<a-radio-group :options="options" @change="onChange2" v-model="value2" />
2017-11-07 03:58:47 +00:00
<br />
2018-04-11 05:32:18 +00:00
<a-radio-group :options="optionsWithDisabled" disabled @change="onChange3" v-model="value3" />
2017-11-07 03:58:47 +00:00
</div>
</template>
<script>
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',
}
},
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)
},
},
}
</script>
2018-04-11 05:32:18 +00:00
```