Skip to content

Radio

基础用法

html

<pa-radio-group v-model="value">
  <pa-radio v-for="item in options" :key="item.name" :name="item.name">
    {{ item.label }}
  </pa-radio>
</pa-radio-group>
<pa-radio-group v-model="value" class="block mt-50">
  <pa-radio v-for="item in options" :key="item.name" :name="item.name" label-position="left">
    {{ item.label }}
  </pa-radio>
</pa-radio-group>
ts

import { ref } from 'vue'

const value = ref<number>(0)

const options = new Array(3).fill(0).map((_item, index) => ({
  name: index,
  label: '单选框' + index,
}))

水平方向

html

<pa-radio-group v-model="value" direction="horizontal">
  <pa-radio v-for="item in options" :key="item.name" :name="item.name">
    {{ item.label }}
  </pa-radio>
</pa-radio-group>
<pa-radio-group v-model="value" direction="horizontal" class="block mt-50">
  <pa-radio v-for="item in options" :key="item.name" :name="item.name" label-position="left">
    {{ item.label }}
  </pa-radio>
</pa-radio-group>
ts

import { ref } from 'vue'

const value = ref<number>(0)

const options = new Array(3).fill(0).map((_item, index) => ({
  name: index,
  label: '单选框' + index,
}))

形状

html

<pa-radio-group v-model="value">
  <pa-radio v-for="item in options" :key="item.name" :name="item.name" shape="square">
    {{ item.label }}
  </pa-radio>
</pa-radio-group>
ts

import { ref } from 'vue'

const value = ref<number>(0)

const options = new Array(3).fill(0).map((_item, index) => ({
  name: index,
  label: '单选框' + index,
}))

禁用

html

<pa-radio-group v-model="value">
  <pa-radio
    v-for="item in options"
    :key="item.name"
    :name="item.name"
    :disabled="item.name === 1"
  >
    {{ item.label }}
  </pa-radio>
</pa-radio-group>
<pa-radio-group v-model="value" disabled class="block mt-50">
  <pa-radio v-for="item in options" :key="item.name" :name="item.name">
    {{ item.label }}
  </pa-radio>
</pa-radio-group>
ts

import { ref } from 'vue'

const value = ref<number>(0)

const options = new Array(3).fill(0).map((_item, index) => ({
  name: index,
  label: '单选框' + index,
}))

Radio Props

参数说明类型默认值
name标识符RadioValue''
shape形状'square'|'round''round'
disabled是否为禁用状态boolean-
labelDisabled是否禁用文本内容点击boolean-
labelPosition文本位置'left'|'right''right'
iconSize图标大小string | number'20px'
checkedColor选中状态颜色CSSProperties['color']-

RadioGroup Props

参数说明类型默认值
name标识符string''
modelValueRadioValue-
direction方向'horizontal'|'vertical''vertical'
disabled是否全部禁用boolean-

Radio Event

事件名参数
change(value: RadioValue)

RadioGroup Event

事件名参数
update:modelValue(value: RadioValue)
change(value: RadioValue, name: string)

Radio Slot

名称说明
default-
default-

RadioGroup Slot

名称说明
default-

样式变量

名称默认值
--pa-radio-size20px
--pa-radio-displayflex
--pa-radio-margin0
--pa-radio-font-size16px
--pa-radio-label-colorvar(--pa-color-black)
--pa-radio-checked-colorvar(--pa-color-primary)
--pa-radio-checked-colorvar(--pa-color-primary)