0
点赞
收藏
分享

微信扫一扫

【Kevin Learn 小程序】-->radio

效果图

【Kevin Learn 小程序】-->radio_ide

属性

参考:​​radio​​

代码

  1. app.js
//app.js
App({
onLaunch: function () {
console.log('App Launch')
},
onShow: function () {
console.log('App Show')
},
onHide: function () {
console.log('App Hide')
},
globalData: {
hasLogin: false
}
})
  1. app.json
{
"pages": [
"pages/radio/radio"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
  1. radio.js
Page({
data: {
items: [
{ value: 'USA', name: '美国' },
{ value: 'CHN', name: '中国', checked: 'true' },
{ value: 'BRA', name: '巴西' },
{ value: 'JPN', name: '日本' },
{ value: 'ENG', name: '英国' },
{ value: 'FRA', name: '法国' },
]
},
radioChange: function (e) {
console.log('radio发生change事件,携带value值为:', e.detail.value)

var items = this.data.items;
for (var i = 0, len = items.length; i < len; ++i) {
items[i].checked = items[i].value == e.detail.value
}

this.setData({
items: items
});
}
})
  1. radio.json
{
"navigationBarTitleText": "radio 组件"
}
  1. radio.wxml
<view class="container">
<view class="page-body">
<view class="page-section page-section-gap">
<view class="page-section-title">默认样式</view>
<label class="radio">
<radio value="r1" checked="true"/>选中
</label>
<label class="radio">
<radio value="r2" />未选中
</label>
</view>


<view class="page-section">
<view class="page-section-title">推荐展示样式</view>
<view class="weui-cells weui-cells_after-title">
<radio-group bindchange="radioChange">
<label class="weui-cell weui-check__label" wx:for="{{items}}" wx:key="{{item.value}}">

<view class="weui-cell__hd">
<radio value="{{item.value}}" checked="true"/>
</view>
<view class="weui-cell__bd">{{item.name}}</view>
</label>
</radio-group>
</view>
</view>
</view>
</view>
  1. radio.wxss
@import "../../common/lib/weui.wxss";

.radio {
margin-right: 20rpx;
}


举报

相关推荐

0 条评论