收藏
回答

Cannot read property 'type1' of undefined什么错误?

求大神搭救啊,,,,,不胜感激

var app = getApp();

// var arr = app.globalData.proArray;

var favo_icon_b = "/images/ico_3_h.png";

var favo_icon_c = "/images/ico_31.png"

var color_right = "#00a0e9";

var color_err = "#eb3b3b";

var color_blank = "#fff";

var __chooseOne = 0;

//题库信息

var prosData = []

var index = 0;

var favo_data = []

//获取要做的题库信息

var randomsort = function (a, b) {

return Math.random() > .5 ? -1 : 1

}

var getPros = function (_chooseOne, _chooseTwo, _random) {

prosData = []

var _prosData = JSON.parse(JSON.stringify(app.globalData.prosData))

var baseData = new Object();

__chooseOne = _chooseOne;

switch (_chooseOne) {

case 1:

baseData = _prosData.sect1;

break;

case 2:

baseData = _prosData.sect2;

break;

case 3:

baseData = _prosData.sect3;

break;

}

var baseData2 = []

var type1Data = []

baseData2 = baseData.type1       提示的错误

type1Data = baseData2.concat(_prosData.sect4.type1)

switch (_chooseTwo) {

case 1:

prosData = type1Data;

break;

case 2:

baseData2 = baseData.type2;

var type2Data = baseData2.concat(_prosData.sect4.type2)

prosData = type1Data.concat(type2Data)

break;

}


onLoad: function (options) {

index=0

prosData = []

console.log(options)

var that = this;

that.inquiryFavo(() => {

if (that.checkFavo()) {

that.setData({

favoIcon: favo_icon_c

})

} else {

that.setData({

favoIcon: favo_icon_b

})

}

})

提示错误处     getPros(parseInt(options.chooseNumOne), parseInt(options.chooseNumTwo), options.random)

console.log(prosData)

if (options.random == "true") {

this.setData({

chooseText: "随机练习"

})

} else {

this.setData({

chooseText: "顺序练习"

})

}

this.setData({

proSum: prosData.length

})

this.loadPro()

},

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

1 个回答

  • o0o有脾气的酸奶
    o0o有脾气的酸奶
    2019-11-25

    说明baseData为undefined

    2019-11-25
    有用
    回复 5
    • stm8l101
      stm8l101
      2019-11-26
      感谢大神的回复,但是,前面baseData这样“var baseData = new Object();”定义了啊,怎么回事呢
      2019-11-26
      1
      回复
    • o0o有脾气的酸奶
      o0o有脾气的酸奶
      2019-11-26回复stm8l101
      开始是定义啦,但是switch里又赋值啦,你确定_prosData.sect1、_prosData.sect2、_prosData.sect3、_prosData.sect4这些不是undefined?
      2019-11-26
      1
      回复
    • o0o有脾气的酸奶
      o0o有脾气的酸奶
      2019-11-26回复stm8l101
      baseData = _prosData.sect1 || {}
      2019-11-26
      1
      回复
    • stm8l101
      stm8l101
      2019-11-26
      谢谢你的耐心回答!
      2019-11-26
      回复
    • stm8l101
      stm8l101
      2019-11-26回复o0o有脾气的酸奶
      确实是这个问题,技术好,人更好,点赞!!!
      2019-11-26
      回复
登录 后发表内容
问题标签