methods:{
async start(){
const res = await fetch(`/driverLicense/queryQuestionList?${ Object.keys(this.form).map(k=> `${k}=${this.form[k]}`).join('&') }`).then(r=> r.json())
if(res.statusCode != "000000") return;
this.list = res.result.driverQuestionList.filter(v=> (v.answerInfo = v.showAnswer = false) || v.questionType != 3)
this.cur = 2;
},
reset(){
this.cur = 1;
this.list = [];
this.listIdx = 0;
},
answer(id){
if(!this.question.showAnswer) this.question.answerInfo = id;
},
next(down){
this.listIdx += (down ? 1 : -1 );
},
sub(){
const len = this.list.length;
const success = this.list.filter(v=> v.answerInfo == v.key).length;
alert(`你答对了${ success }道题,答错了${ len - success }道题. 最终得分: ${ (success / len * 100).toFixed(2)}分`)
}
}
}
methods:{
async start(){
const res = await fetch(`/driverLicense/queryQuestionList?${ Object.keys(this.form).map(k=> `${k}=${this.form[k]}`).join('&') }`).then(r=> r.json())
if(res.statusCode != "000000") return;
this.list = res.result.driverQuestionList.filter(v=> (v.answerInfo = v.showAnswer = false) || v.questionType != 3)
this.cur = 2;
},
reset(){
this.cur = 1;
this.list = [];
this.listIdx = 0;
},
answer(id){
if(!this.question.showAnswer) this.question.answerInfo = id;
},
next(down){
this.listIdx += (down ? 1 : -1 );
},
sub(){
const len = this.list.length;
const success = this.list.filter(v=> v.answerInfo == v.key).length;
alert(`你答对了${ success }道题,答错了${ len - success }道题. 最终得分: ${ (success / len * 100).toFixed(2)}分`)
}
}
}
start获取问题列表,reset回到第一题,answer将问题标记为已回答,next切换上一题下一题,sub计算结果
不就是5个函数嘛?代码逻辑也很简单,哪里看不明白?