微信小程序修改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}}的值
相关推荐
镭封8 小时前
自媒体内容生产怎么提速?文案整理、配音与剪辑流程
人工智能·小程序·音视频·语音识别·媒体
科威网络9 小时前
小程序开发性能优化:分包、预加载与启动时间
性能优化·微信小程序·小程序
派小心.15 小时前
App数据统计平台怎么选?从SDK接入到日活留存看板的技术实现
数据库·人工智能·小程序
互联网+人工智能观察16 小时前
微信小程序私有化定制、源码交付方案选型|SaaS / 模板二开 / 定制方案技术对比
微信小程序·小程序
微三云 - 廖会灵 (私域系统开发)16 小时前
小程序首屏从 3.2s 压到 1.1s:我们在这个订货商城项目上做的 7 个改动与 3 个踩坑
小程序
微擎应用市场17 小时前
二手闲置交易小程序管理系统
小程序
小小王app小程序开发17 小时前
潮玩抽赏小程序玩法开发分析
小程序
干啥啥不行,bug第一名17 小时前
小程序里不要用 requestAnimationFrame
小程序
96245617 小时前
一次 Kubernetes 临时存储压力引发的小程序授权雪崩:从 Pod 驱逐到定时任务漏执行
容器·小程序·kubernetes
imperialeast1 天前
WinAXP 2.4.0.830正式版
小程序·个人开发