修改checked值无法解决
wxml中
{{index + 1}} . {{datas[index].title}}
{{datas[index].items[0].value}}
{{datas[index].items[1].value}}
{{datas[index].items[2].value}}
{{datas[index].items[3].value}}
下一题
js中
var app = getApp();
Page({
data: {
index:0,
datas:[
{
"id":1,
"items":[
{ "name": "A", "value": "A. 0" },
{ "name": "B", "value": "B. 1" },
{ "name": "C", "value": "C. 2" },
{ "name": "D", "value": "D. 3" }
],
"kind":"1",
"result":"C",
"title":"1+1=?"
},
{
"id": 2,
"items": [
{ "name": "A", "value": "A. 0" },
{ "name": "B", "value": "B. 1" },
{ "name": "C", "value": "C. 2" },
{ "name": "D", "value": "D. 3" }
],
"kind": "1",
"result": "D",
"title": "1+2=?"
},
]
},
exam:function(){
console.log("index:"+this.data.index);
var currPage = this;
var currIndex = currPage.data.index + 1;
if(currIndex==5){
wx.redirectTo({
url: '/pages/result/result',
})
}
currPage.setData({
index:currIndex
});
},
onReady: function(){
app.examData.examDatas = this.data.datas;
console.log(app.examData.examDatas[0].title)
}
})
初始化checked值为false
radio | 微信开放文档
https://developers.weixin.qq.com/miniprogram/dev/component/radio.html
初始化checked值