// 判断所选择的选项是否为正确答案
chooseJudge(){
var trueValue = this.data.questionList[this.data.index].daan['true'];
var chooseVal = this.data.chooseValue[this.data.index];
if (chooseVal.toString() != trueValue.toString()) {
// 答错则记录错题
this.data.wrong++;
this.data.wrongListSort.push(this.data.index);
this.data.wrongList.push(this.data.questionList[this.data.index]._id);
}else{
// 答对则累计总分
this.setData({
totalScore: this.data.totalScore + 5
})
}
},
// 判断是不是最后一题
lastJudge(){
if (this.data.index < this.data.questionList.length - 1) {
// 如果不是最后一题,则切换下一题
let index = this.data.index + 1;
this.setData({
index
})
} else {
// 如果是最后一题,则提交答卷
this.addExamRecord()
}
},
// 提交答卷
addExamRecord(){
wx.showLoading({
title: '提交答卷中'
});
let examResult = {
wrong: this.data.wrong,
totalScore: this.data.totalScore
};
没取到这个toString得值,你取值得时候先console看看能不能取到值