Home >WeChat Applet >Mini Program Development >Detailed explanation of WeChat applet component: radio single selection item
radio single-select item component description:
radio: single-select item.
radio-group:
Single-item selector, internally composed of multiple
The radio single-select item sample code runs as follows:
The following is the WXML code:
<view class="page"> <view class="page__hd"> <text class="page__title">radio</text> <text class="page__desc">单选框</text> </view> <view class="page__bd"> <view class="section section_gap"> <radio-group class="radio-group" bindchange="radioChange"> <label class="radio" wx:for="{{items}}"> <radio value="{{item.name}}" checked="{{item.checked}}"/>{{item.value}} </label> </radio-group> </view> </view> </view>
The following is the JS code:
Page({ data: { items: [ {name: 'USA', value: '美国'}, {name: 'CHN', value: '中国', checked: 'true'}, {name: 'BRA', value: '巴西'}, {name: 'JPN', value: '日本'}, {name: 'ENG', value: '英国'}, {name: 'FRA', value: '法国'}, ] }, radioChange: function(e) { console.log('radio发生change事件,携带value值为:', e.detail.value) } })
The following is the WXSS code:
page { min-height: 100%; flex: 1; background-color: #FBF9FE; font-size: 32rpx; font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; overflow: hidden; } .page__hd{ padding: 50rpx 50rpx 100rpx 50rpx; text-align: center; } .page__title{ display: inline-block; padding: 20rpx 40rpx; font-size: 32rpx; color: #AAAAAA; border-bottom: 1px solid #CCCCCC; } .page__desc{ display: none; margin-top: 20rpx; font-size: 26rpx; color: #BBBBBB; } .radio { display: block; margin-bottom: 20rpx; } .section{ margin-bottom: 80rpx; } .section_gap{ padding: 0 30rpx; }
The main attributes of the radio single-item item:
radio-group:
radio :
The above is the detailed content of Detailed explanation of WeChat applet component: radio single selection item. For more information, please follow other related articles on the PHP Chinese website!