微信小程序修改radio的样式

复制代码
        <radio-group bindchange="radioChange">
          <label class="flRlist" wx:for="{{productList}}" wx:key="index">           
            <view class="flName">{{item.name}}</view>
            <view class="flZT">
              <radio color="#74bfe7" style="transform:scale(0.8);" value="{{item.value}}" checked="true"  class="flxzys"/>
            </view>
          </label>
        </radio-group>

radio .wx-radio-input{width:35rpx;height:35rpx;border-radius:50%;border:2rpx solid #000;background:0 0}
radio .wx-radio-input.wx-radio-input-checked{width:35rpx;height:35rpx;border:2rpx solid #000;background-color:#fff!important}
radio .wx-radio-input.wx-radio-input-checked::before{width:35rpx;height:35rpx;border-radius:50%;width:20rpx;height:20rpx;line-height:20rpx;text-align:center;font-size:0rpx;color:transparent;background:#000;transform:translate(-50%,-50%) scale(1)}

  data: {
    productList: [
      {value: 'USA', name: '美国'},
      {value: 'CHN', name: '中国', checked: 'true'},
      {value: 'BRA', name: '巴西'},
      {value: 'JPN', name: '日本'},
      {value: 'ENG', name: '英国'},
      {value: 'FRA', name: '法国'},
    ]
  },

二:

复制代码
<view class="flZT">
              <radio color="#74bfe7" style="transform:scale(0.8);" value="{{item.value}}" checked="true"  class="flxzys"/>
            </view>

注解:

bindchange:有变化执行事件

wx:for-items:表示对{{items}}进行循环

<radio>中的color属性:主要设置选中之后图标颜色

<radio>中的style属性:这里主要用来展示图标的大,scale缩放

<radio>中的value属性:主要用于事件bindchange执行之后能获取到值

<radio>中的checked属性:设置默认值

复制代码
  //单选
  radioChange:function(e){
    //获取单选数据
    console.log(e.detail.value)//输出的是{{item.name}}的值
相关推荐
流***陌2 小时前
宠物寄养美容小程序前端功能解析:贴心照料宠物的全流程支撑
小程序·宠物
小小王app小程序开发5 小时前
任务悬赏小程序深度细分分析:非技术视角下的运营逻辑拆解
大数据·小程序
2501_915918416 小时前
iOS 26 App 性能测试|性能评测|iOS 26 性能对比:实战策略
android·macos·ios·小程序·uni-app·cocoa·iphone
腾马科技12 小时前
新版saas餐饮外卖小程序源码/微信/支付宝/抖音/扫码点餐/DIY装修/美团代付/全开源
微信小程序·小程序·点餐小程序
郑叔敲代码17 小时前
帝国cms 微信小程序的登录逻辑
微信小程序·小程序·notepad++
棋子一名20 小时前
跑马灯组件 Vue2/Vue3/uni-app/微信小程序
微信小程序·小程序·uni-app·vue·js
无衣 秦风21 小时前
vue3+hubuilderX开发微信小程序使用elliptic生成ECDH密钥对遇到的问题
微信小程序·小程序
游戏开发爱好者821 小时前
BShare HTTPS 集成与排查实战,从 SDK 接入到 iOS 真机调试(bshare https、签名、回调、抓包)
android·ios·小程序·https·uni-app·iphone·webview
2501_916008891 天前
iOS 26 系统流畅度实战指南|流畅体验检测|滑动顺畅对比
android·macos·ios·小程序·uni-app·cocoa·iphone
流***陌1 天前
陪诊就医小程序中健康档案的精细化管理设计方案
小程序