<view class="section1">
<label >是否扣课: </label>
<radio-group class="radio-group" bindchange="radioChange">
<label class="radio" wx:for="{{items}}" wx:key="key">
<radio value="{{item.name}}" checked="{{item.checked}}"/>{{item.value}}
</label>
</radio-group>
</view>
==================================================
data: {
items: [
{ name: 'Y', value: '是' },
{ name: 'N', value: '否', checked: 'true' },
],
......
}
=========================================================
点击一个按钮后,要改变checked
toUpdate:function(event)
{
console.log(this.data.items);
db.collection("kinds").doc(event.currentTarget.dataset.cid).get().then(
res=>{
if(res.data.addyn=='Y')
{
this.data.items[0].checked="true";
this.data.items[1].checked="false";
this.setData({
items: this.data.items
})
console.log(this.data.items)
}
}
)
},
为什么打印出来两个都是
- nv_length: (...)
- 0: {name: "Y", value: "是", checked: "true"}
- 1: {name: "N", value: "否", checked: "false"}
- length: 2
- __proto__: Array(0)
第一次打印不是应该第二个选项是false?
而且这样运行后前台的选择也没变,还是选中了否那项
这是怎么回事?