更新记录
1.0.0(2025-02-18)
下载此版本
发布初版
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
app-vue |
× |
√ |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
Radio 单选框
组件名: xt-radio
适配情况需自行尝试,开发时只测试了H5、APP、微信小程序
安装方式
本组件符合 easycom 规范,HBuilderX 3.1.0 起,只需将本组件导入项目,在页面 template 中即可直接使用,无需在页面中 import 和注册 components
基本用法
<template>
<view class="xt">
<xt-radio v-model="radio" @change='change'>
<xt-radio-item label="选项1" value="1"></xt-radio-item>
<xt-radio-item label="选项2" value="2"></xt-radio-item>
</xt-radio>
<button @click="log">打印</button>
</view>
</template>
<script>
export default {
data() {
return {
radio: '1'
}
},
methods: {
log() {
console.log(this.radio);
},
change(e) {
console.log(e);
}
}
}
</script>
<style lang="scss">
.xt {
padding: 0 20rpx;
display: flex;
flex-direction: column;
gap: 15rpx;
}
</style>
xt-radio API
属性名 |
类型 |
说明 |
默认值 |
value |
String|Number|Boolean |
绑定的值 |
|
placement |
String |
布局方式, 可选 column |
row |
disabled |
Boolean |
是否禁用所有 radio |
false |
round |
Boolean |
是否圆形框 |
false |
activeColor |
String |
选中时的颜色,应用到所有子 Radio 组件 |
#2979ff |
inactiveColor |
String |
未选中的颜色 |
#fff |
size |
String | Number |
组件整体的大小 |
36rpx |
labelColor |
String |
label 的颜色 |
#000 |
labelAlign |
String |
文字布局方向 |
right |
endAlignment |
Boolean |
是否两端对齐 |
false |
iconColor |
String |
图标颜色 |
#ffffff |
borderBottom |
Boolean |
placement 为 row 时,是否显示下边框 |
false |
xt-radio Events
事件名 |
参数 |
说明 |
change |
- |
当选择值变化时触发 |
xt-radio-item API
属性名 |
类型 |
说明 |
默认值 |
value |
String|Number|Boolean |
选中值 |
|
label |
String |
提示文字 |
|
disabled |
Boolean |
是否禁用 |
false |