naive-ui/demo/documentation/components/radio/enUS/buttonGroup.md

87 lines
2.0 KiB
Markdown
Raw Normal View History

2019-10-21 14:49:08 +08:00
# Button Group
2020-01-28 23:15:39 +08:00
Sometimes a radio button group looks more elegant.
2019-10-21 14:49:08 +08:00
```html
2020-01-28 23:15:39 +08:00
<div style="margin-bottom: 12px;">
2020-02-14 15:27:45 +08:00
<n-radio-group v-model="value" name="radiobuttongroup">
2020-01-28 23:15:39 +08:00
<n-radio-button
v-for="song in songs"
:key="song.value"
:value="song.value"
:disabled="(song.label === 'Live Forever' && disabled1 || song.label === 'Shakermaker' && disabled2)"
>
{{ song.label }}
</n-radio-button>
</n-radio-group>
</div>
<div style="margin-bottom: 12px;">
<n-radio-group v-model="value" name="radiobuttongroup" size="medium">
<n-radio-button
v-for="song in songs"
:key="song.value"
:value="song.value"
:disabled="(song.label === 'Live Forever' && disabled1 || song.label === 'Shakermaker' && disabled2)"
>
{{ song.label }}
</n-radio-button>
</n-radio-group>
</div>
<div style="margin-bottom: 12px;">
<n-radio-group v-model="value" name="radiobuttongroup" size="large">
<n-radio-button
v-for="song in songs"
:key="song.value"
:value="song.value"
2020-01-28 23:15:39 +08:00
:disabled="(song.label === 'Live Forever' && disabled1 || song.label === 'Shakermaker' && disabled2)"
>
{{ song.label }}
</n-radio-button>
</n-radio-group>
</div>
2019-10-21 14:49:08 +08:00
<n-checkbox
v-model="disabled2"
style="margin-right: 12px;"
>
2020-02-04 17:18:32 +08:00
Disable Shakemaker
2019-10-21 14:49:08 +08:00
</n-checkbox>
<n-checkbox
v-model="disabled1"
>
2020-02-04 17:18:32 +08:00
Disable Live Forever
2019-10-21 14:49:08 +08:00
</n-checkbox>
```
```js
export default {
data () {
return {
value: null,
disabled2: false,
disabled1: false,
songs: [
{
value: 'Rock\'n\'Roll Star',
label: 'Rock\'n\'Roll Star'
},
{
value: 'Shakermaker',
label: 'Shakermaker'
},
{
value: 'Live Forever',
label: 'Live Forever'
},
{
value: 'Up in the Sky',
label: 'Up in the Sky'
},
{
value: '...',
label: '...'
}
].map(s => {
s.value = s.value.toLowerCase()
return s
})
}
}
}
```