收藏
回答

为什么在下面的窗口result能显示,在左边的窗口结果显示为null,求大佬解答,谢谢?

result.js中的代码
 /**
   * 页面的初始数据
   */
  data: {
    A: 0,
    B: 0,
    C: 0,
    D: 0,
    score: 0,
    result: 0
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   console.log(options)
    this.setData({
      A: options.A - 0,
      B: options.B - 0,
      C: options.C - 0,
      D: options.D - 0,
      score: options.score -0,
      result: options.result - 0
    })

test.js中的代码
Page({
  /**
   * 页面的初始数据
   */
  data: {
    index: 1,
    realIndex: 0,
    A: 0,
    B: 0,
    C: 0,
    D: 0,
    a:0,
    b:0,
    c:0,
    d: 0,
    optionA: "A",
    optionB: "B",
    optionC: "C",
    optionD: "D",
    questionDetail: app.globalData.question[0].question,
    answerA: app.globalData.question[0].option.A,
    answerB: app.globalData.question[0].option.B,
    answerC: app.globalData.question[0].option.C,
    answerD: app.globalData.question[0].option.D,
    list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
    listABC : ['A','B','C','D'],
    score: 0,
    result: 0
  },
 
  // randSort: function () {
  //   return Math.random() > 0.5 ? 1 : -1;
  // },
  // setList: function () {
  //   var newList = this.data.list.sort(this.randSort);
  //   this.setData({
  //     list: newList,
  //   });
  // },
  // setABC : function(){
  //   var abc = this.data.listABC.sort(this.randSort);
  //   this.setData({
  //     listABC: abc,
  //   });
  // },
  setOption: function(){
  },

  answerClickA: function () {
    this.setData({
      A: this.data.A + 1
    })
    this.setData({
      score: this.data.score + 1.25
    })
    if (this.data.index == 20) {
      if (this.data.score <= 52) {
        this.setData({
          result:  '正常'
        })
      }
      if (53 <= this.data.score <= 62) {
        this.setData({
          result:  '轻度抑郁'
        })
      }
      if (63 <= this.data.score <= 72) {
        this.setData({
          result:  '中度抑郁'
        })
      }
      if (73 <= this.data.score ){
        this.setData({
          result:  '重度抑郁'
        })
      }
      wx.redirectTo({
        url: '/pages/result/result?A=' + this.data.A + '&B=' + this.data.B + '&C=' + this.data.C + '&D=' + this.data.D + '&score=' + this.data.score + '&result= ' + this.data.result,
      })
    }
    if(this.data.index < 20){
    this.setData({
      index: this.data.index + 1,
      realIndex: this.data.list[this.data.index],
    })
    this.setData({
      questionDetail: app.globalData.question[this.data.realIndex].question,
     
      answerA: app.globalData.question[this.data.realIndex].option[this.data.listABC[0]],
      answerB: app.globalData.question[this.data.realIndex].option[this.data.listABC[1]],
      answerC: app.globalData.question[this.data.realIndex].option[this.data.listABC[2]],
      answerD: app.globalData.question[this.data.realIndex].option[this.data.listABC[3]],
    }) 
  }
  },

回答关注问题邀请回答
收藏

1 个回答

  • H1HAO 🇨🇳
    H1HAO 🇨🇳
    2020-06-09

    你看下页面渲染是不是写错了


    2020-06-09
    有用
    回复
登录 后发表内容
问题标签