微信小程序修改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}}的值
相关推荐
Emma歌小白1 天前
如何首次运行小程序后端
微信小程序
赣州云智科技的技术铺子1 天前
【一步步开发AI运动APP】十二、自定义扩展新运动项目1
微信小程序·小程序·云开发·智能小程序
2501_915918411 天前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张1 天前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
破无差1 天前
《赛事报名系统小程序》
小程序·html·uniapp
00后程序员张1 天前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
海绵宝宝不喜欢侬2 天前
uniapp-微信小程序分享功能-onShareAppMessage
微信小程序·小程序·uni-app
2501_915106322 天前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
亮子AI2 天前
【小程序】微信小程序隐私协议
微信小程序·小程序
weixin_177297220692 天前
短剧小程序系统开发:打造个性化娱乐新平台
小程序·娱乐·短剧