naive-ui/demo/documentation/components/radio/zhCN/group.demo.md
2020-09-29 00:56:27 +08:00

868 B

选项组

一个选项组看起来就挺舒服。

<n-radio-group
  v-model:value="value"
  name="radiogroup"
>
  <n-radio
    v-for="song in songs"
    :key="song.value"
    :value="song.value"
  >
    {{ song.label }}
  </n-radio>
</n-radio-group>
export default {
  data () {
    return {
      value: null,
      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
      })
    }
  }
}