Skip to content

m-radio-group 单选组

简述

m-radio-groupm-radio 配合使用,在一组互斥选项中选中一项,通过 v-model 绑定当前选中项的 value(字符串)。

IMPORTANT

本组件为 mmsUnix 自研;请勿与外部未授权商业组件源码混用或逐字对照非本库文档,以免授权风险。

注意

请以 uni_modules/m-unix 与本文为准;各端差异以 uni-app 与各平台官方文档为准。涉及隐私能力(相册、定位、剪贴板、手机号等)需在 manifest 与后台完成配置。

平台差异说明

App(vue)App(nvue)H5小程序

演示地址

与线上 H5 演示基座 分包一致(文档站右下角预览 iframe 亦指向同一路径)。

类型地址
分包路径pages_demo/radio/radio
线上 H5(hash)打开演示

基本使用

uvue
<template>
	<m-radio-group v-model="payType" name="payType" direction="row">
		<m-radio value="wx">
			<text>微信支付</text>
		</m-radio>
		<m-radio value="ali">
			<text>支付宝</text>
		</m-radio>
	</m-radio-group>
</template>

注意m-radio 必须放在 m-radio-group 内;子项 value 建议为非空字符串,并与组的 modelValue 严格相等才会显示为选中。子项 API 见 m-radio

Props

参数说明类型默认值
modelValue当前选中的 m-radiovaluestring''
name字段名(便于业务语义,不参与原生 form 提交)string''
disabled整组禁用booleanfalse
color子项未单独设置 color 时的默认选中填充色string''(子项内默认 #5677fc
borderColor子项未单独设置 borderColor 时的默认边框色string''(子项内默认 #cccccc
directioncolumn 纵向 / row 横向stringcolumn

Events

事件名说明回调参数
update:modelValuev-model 更新选中的 value
inputupdate:modelValue 同步触发选中的 value
change选中项变化选中的 value

插槽

名称说明
default多个 m-radio

与表单组合

可与 m-formm-input 同页使用。演示见:

  • /pages_demo/form/form:资料登记中的「性别」行
  • /pages_demo/radio/radio:单选能力分项示例

与 m-segmented-control 的区别

场景建议
分段切换、文案短、条状 UIm-segmented-control
表单问卷、带自定义文案/禁用项、圆形单选视觉m-radio-group + m-radio

Released under the MIT License.