收藏
回答

radio,一个页面有一道选择题,在第一个页面选择C后,第二个页面初始就自动选择C,怎么解决?

修改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();//用来将本页提取到app.js中的关键

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=?"
      },
    ]
  },
//currIndex是下一题题号,currPage是当前页面对象
  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)
  }

 
})
最后一次编辑于  2020-03-31
回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容
问题标签