Skip to content

Radio 单选

用于在一组选项中选择一个值,提供单个 <mc-radio> 与选项组 <mc-radio-group>

单选组

mode = survival
vue
<script setup lang="ts">
import { ref } from 'vue'
const mode = ref('survival')
</script>

<template>
  <mc-radio-group
    v-model="mode"
    :options="[
      { label: '生存', value: 'survival' },
      { label: '创造', value: 'creative' }
    ]"
  />
</template>

垂直排列

vue
<script setup lang="ts">
import { ref } from 'vue'
const difficulty = ref('normal')
</script>

<template>
  <mc-radio-group
    v-model="difficulty"
    direction="vertical"
    :options="[
      { label: '和平', value: 'peaceful' },
      { label: '简单', value: 'easy' },
      { label: '普通', value: 'normal' },
      { label: '困难', value: 'hard' }
    ]"
  />
</template>

单个 Radio

vue
<script setup lang="ts">
import { ref } from 'vue'
const mode = ref('survival')
</script>

<template>
  <mc-radio v-model="mode" value="survival">生存</mc-radio>
  <mc-radio v-model="mode" value="creative">创造</mc-radio>
</template>

mc-radio Props

名称类型默认说明
modelValuestring | number | boolean''当前选中值(v-model)
valuestring | number | boolean''当前单选项值
disabledbooleanfalse是否禁用

mc-radio-group Props

名称类型默认说明
modelValuestring | number | boolean''当前选中值(v-model)
optionsMcRadioOption[][]选项列表
direction'horizontal' | 'vertical'horizontal排列方向
disabledbooleanfalse是否整组禁用

Events

事件参数说明
update:modelValuestring | number | booleanv-model 更新
changestring | number | boolean值变化

MIT Licensed · 设计语言移植自 Spectrollay-McUI