做了一个多选和单选按钮测试,发现有一个按钮总是选不上或勾不掉,不知@白开水 老师有无办法
页面:
<radio-group bindchange=‘radio1Change’>
<label style=‘display:block’ wx:for=’{{items1}}’ wx:key=‘name’>
<radio value=’{{item.name}}’ checked=’{{item.checked}}’></radio>
{{item.value}}
</label>
</radio-group>
<view style=‘margin-top:30rpx;margin-bottom:30rpx;border-top:1px solid #000’>
</view>
<radio-group bindchange=‘radio2Change’>
<label style=‘display:block’ wx:for=’{{items2}}’ wx:key=‘name’>
<radio value=’{{item.name}}’ checked=’{{item.checked}}’></radio>
{{item.value}}
</label>
</radio-group>
js代码:
Page({
/**
* 页面的初始数据
*/
data: {
items1: [
{ name: ‘USA’, value: ‘美国’ },
{ name: ‘CHN’, value: ‘中国’},
{ name: ‘BRA’, value: ‘巴西’ },
{ name: ‘JPN’, value: ‘日本’ },
{ name: ‘ENG’, value: ‘英国’ },
{ name: ‘TUR’, value: ‘法国’ },
],
items2: [
{ name: ‘BEIJING’, value: ‘北京’, checked: ‘true’ },
{ name: ‘SHANGHAI’, value: ‘上海’ },
{ name: ‘shanGDONG’, value: ‘山东’ },
{ name: ‘GUANGDONG’, value: ‘广东’ },
{ name: ‘SHENZHEN’, value: ‘深圳’ },
{ name: ‘HANGZHOU’, value: ‘杭州’ }
],
selectedItem1: [],
selectedItem2: []
},
radio1Change: function (e) {
var selectedItems = e.detail.value;
console.log(‘checkBox1发生的change事件,携带value值为’, selectedItems)
this.setData({
selectedItems1: selectedItems
})
console.log(‘data中的selectedItems1的值:’, this.data.selectedItems1)
},
radio2Change: function (e) {
var selectedItems = e.detail.value;
console.log(‘checkBox2发生的change事件,携带value值为’, e.detail.value)
this.setData({
selectedItems2: selectedItems
})
console.log(‘data中的selectedItems2的值:’, this.data.selectedItems2)
}
})