Radio 单选
组件类型:UxRadioComponentPublicInstance、UxRadioGroupComponentPublicInstance
平台兼容性
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | x |
单选 UxRadioComponentPublicInstance
可搭配 ux-radio-group
使用
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
value | String | - | 值 |
name | String | primary | 标识符,在回调事件中返回 |
theme | String | primary | 主题颜色 |
mode | String | radio | 单选模式 |
shape | String | circle | 形状,mode=radio时有效 |
text | String | - | 文案 |
size | Number | $ux.Conf.fontSize | 字体大小 |
color | String | $ux.Conf.fontColor | 文本颜色 |
darkColor | String | - | 深色 |
backgroundColor | String | $ux.Conf.backgroundColor | radio背景色 |
backgroundDark | String | - | 深色 |
activeBackgroundColor | String | $ux.Conf.primaryColor | radio背景选择颜色 |
activeBackgroundDark | String | - | 深色 |
borderColor | String | $ux.Conf.borderColor | radio边框色 |
activeBorderColor | String | $ux.Conf.primaryColor | radio边框选择颜色 |
disabled | Boolean | false | 是否禁用 |
readonly | Boolean | false | 只读 |
direction
值 | 说明 |
---|---|
row | 水平 |
col | 垂直 |
theme
值 | 说明 |
---|---|
primary | 主色 |
warning | 警告 |
success | 成功 |
error | 错误 |
info | 文本 |
mode
值 | 说明 |
---|---|
radio | 单选 |
button | 按钮 |
cell | 单元格 |
shape
值 | 说明 |
---|---|
circle | 圆形 |
square | 方形 |
Events
事件名 | 说明 | 参数 |
---|---|---|
change | 值改变时触发 | event: Function |
单选组 UxRadioGroupComponentPublicInstance
需搭配 ux-radio
使用
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
direction | String | row | 方向 |
theme | String | primary | 主题颜色 |
checked | Boolean | false | 选择状态 优先级最高 |
value | String | - | 值 |
mode | String | radio | 单选模式 |
shape | String | circle | 形状,mode=radio时有效 |
size | Number | $ux.Conf.fontSize | 字体大小 |
color | String | $ux.Conf.fontColor | 文本颜色 |
darkColor | String | - | 深色 |
backgroundColor | String | $ux.Conf.backgroundColor | radio背景色 |
backgroundDark | String | - | 深色 |
activeBackgroundColor | String | $ux.Conf.primaryColor | radio背景选择颜色 |
activeBackgroundDark | String | - | 深色 |
borderColor | String | $ux.Conf.borderColor | radio边框色 |
activeBorderColor | String | $ux.Conf.primaryColor | radio边框选择颜色 |
disabled | Boolean | false | 是否禁用 |
readonly | Boolean | false | 只读 |
direction
值 | 说明 |
---|---|
row | 水平 |
col | 垂直 |
theme
值 | 说明 |
---|---|
primary | 主色 |
warning | 警告 |
success | 成功 |
error | 错误 |
info | 文本 |
mode
值 | 说明 |
---|---|
radio | 单选 |
button | 按钮 |
cell | 单元格 |
shape
值 | 说明 |
---|---|
circle | 圆形 |
square | 方形 |
Events
事件名 | 说明 | 参数 |
---|---|---|
change | 值改变时触发 | event: Function |
示例代码
html
<template>
<ux-page>
<ux-navbar :title="title" :border="false"></ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag" title="单选框" :bold="true">
<ux-text text="支持单选、单选组,支持单选框、按钮、单元格3种显示模式"></ux-text>
<ux-row :flex="true" align="top" :mt="5" style="width: 100%;">
<ux-text text="详细文档:"></ux-text>
<ux-text style="flex: 1" name="单选框" text="https://www.uxframe.cn/component/form/radio.html" mode="link"></ux-text>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="单选" :bold="true">
<ux-text text="单选模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-row>
<ux-radio value="1" text="uniapp-x" theme="primary" :mr="10"></ux-radio>
<ux-radio value="2" text="flutter" theme="success" :mr="10"></ux-radio>
<ux-radio value="3" text="禁用" theme="error" :disabled="true"></ux-radio>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="单选组" :bold="true">
<ux-text text="单选组模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-col>
<ux-radio-group v-model="value">
<ux-radio value="1" text="uniapp-x" color="red" :mr="10"></ux-radio>
<ux-radio value="2" text="flutter" color="blue" :mr="10"></ux-radio>
<ux-radio value="3" text="禁用" color="green" :disabled="true"></ux-radio>
</ux-radio-group>
</ux-col>
</ux-card>
<ux-card direction="column" icon="arrowright" title="按钮" :bold="true">
<ux-text text="按钮模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-row>
<ux-radio-group v-model="value" mode="button" direction="col">
<ux-radio value="1" text="按钮1" shape="square" theme="primary"></ux-radio>
<ux-radio value="2" text="按钮2" theme="success" :mt="5"></ux-radio>
<ux-radio value="3" text="禁用" :disabled="true" :mt="5"></ux-radio>
</ux-radio-group>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="单元格" :bold="true">
<ux-text text="单元格模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-col>
<ux-radio-group v-model="value" mode="cell" active-background-color="black" active-border-color="black" direction="col">
<ux-radio value="1" text="单元格1" color="red"></ux-radio>
<ux-radio value="2" text="单元格2" shape="square"></ux-radio>
<ux-radio value="3" text="禁用" :disabled="true"></ux-radio>
</ux-radio-group>
</ux-col>
</ux-card>
<ux-card direction="column" icon="arrowright" title="插槽" :bold="true">
<ux-text text="支持插槽自定义内容" :mb="15"></ux-text>
<ux-row>
<ux-radio-group v-model="value" shape="square" theme="error" direction="col">
<ux-radio value="1">
<ux-text text="我是插槽1"></ux-text>
</ux-radio>
<ux-radio :mt="10" value="2">
<ux-text text="我是插槽2"></ux-text>
</ux-radio>
</ux-radio-group>
</ux-row>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="wink" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
<template>
<ux-page>
<ux-navbar :title="title" :border="false"></ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag" title="单选框" :bold="true">
<ux-text text="支持单选、单选组,支持单选框、按钮、单元格3种显示模式"></ux-text>
<ux-row :flex="true" align="top" :mt="5" style="width: 100%;">
<ux-text text="详细文档:"></ux-text>
<ux-text style="flex: 1" name="单选框" text="https://www.uxframe.cn/component/form/radio.html" mode="link"></ux-text>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="单选" :bold="true">
<ux-text text="单选模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-row>
<ux-radio value="1" text="uniapp-x" theme="primary" :mr="10"></ux-radio>
<ux-radio value="2" text="flutter" theme="success" :mr="10"></ux-radio>
<ux-radio value="3" text="禁用" theme="error" :disabled="true"></ux-radio>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="单选组" :bold="true">
<ux-text text="单选组模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-col>
<ux-radio-group v-model="value">
<ux-radio value="1" text="uniapp-x" color="red" :mr="10"></ux-radio>
<ux-radio value="2" text="flutter" color="blue" :mr="10"></ux-radio>
<ux-radio value="3" text="禁用" color="green" :disabled="true"></ux-radio>
</ux-radio-group>
</ux-col>
</ux-card>
<ux-card direction="column" icon="arrowright" title="按钮" :bold="true">
<ux-text text="按钮模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-row>
<ux-radio-group v-model="value" mode="button" direction="col">
<ux-radio value="1" text="按钮1" shape="square" theme="primary"></ux-radio>
<ux-radio value="2" text="按钮2" theme="success" :mt="5"></ux-radio>
<ux-radio value="3" text="禁用" :disabled="true" :mt="5"></ux-radio>
</ux-radio-group>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="单元格" :bold="true">
<ux-text text="单元格模式,可自定义样式和禁用组件" :mb="15"></ux-text>
<ux-col>
<ux-radio-group v-model="value" mode="cell" active-background-color="black" active-border-color="black" direction="col">
<ux-radio value="1" text="单元格1" color="red"></ux-radio>
<ux-radio value="2" text="单元格2" shape="square"></ux-radio>
<ux-radio value="3" text="禁用" :disabled="true"></ux-radio>
</ux-radio-group>
</ux-col>
</ux-card>
<ux-card direction="column" icon="arrowright" title="插槽" :bold="true">
<ux-text text="支持插槽自定义内容" :mb="15"></ux-text>
<ux-row>
<ux-radio-group v-model="value" shape="square" theme="error" direction="col">
<ux-radio value="1">
<ux-text text="我是插槽1"></ux-text>
</ux-radio>
<ux-radio :mt="10" value="2">
<ux-text text="我是插槽2"></ux-text>
</ux-radio>
</ux-radio-group>
</ux-row>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="wink" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
ts
<script setup>
let title = ''
const value = ref('')
onLoad((e: OnLoadOptions) => {
title = e['title'] ?? ''
})
</script>
<script setup>
let title = ''
const value = ref('')
onLoad((e: OnLoadOptions) => {
title = e['title'] ?? ''
})
</script>
css
<style lang="scss">
</style>
<style lang="scss">
</style>