1. 程式人生 > 其它 >c++--函式過載

c++--函式過載

1、請求答題介面

2、判斷使用者是否答對,答對的話跳到下一題,答錯的話彈窗告訴使用者有錯題,請重新答題

Vue實現答題功能

<div class="active_title">
      <span>{{ orderTitle }}</span>
</div>
<p v-show="toanswer" ref="question">{{ title }}</p>
<div class="answer-btns" @click="answerClick($event)">
    <span class="answer-btn" :class="`${isRight && iwww.cppcns.com
tem.result == 1?'right':''}`" v-for="item in answer" :data-result='item.result'>{{ item.name }} <i class="iconfont icon-wrong">&#xe677;</i><i v-show="isRight && item.result == 1" class="iconfont icon-right">&#xe678;</i> </span> </div>
getAllData() {
   this.$axios.get(答題介面).then((res)=>{
     if(parseInt(res.data.err
程式設計客棧
Code)>=0){ this.allData=res.data.data if(this.allData.question.length > 0) { this.toanswer = true } this.title = this.allData.question[0].title//第幾題 this.answer = this.allData.question[0].answner//第幾題問題 }else{ this.toast = this.$createToast({ txt: res.data.message,type: 'txt' }) this.toast.show() } }).catch((err)=>{ console.log(err) }) },answerClick(e){ consttar=e.target,className=e.target.className if(className=="answer-btn"){ this.mask=true constresult=tar.dataset.result if(result==1){ //console.log('選對',result); this.isRight=true $(tar).addClass('right') }else{ //console.log('選錯',result); this.isRight=true this.ihttp://www.cppcns.com
sWrong=true $(tar).addClass('wrong') setTimeout(()=>{ this.maskTips=true },1200); } setTimeout(()=>{ this.clickNum++ if(this.clickNum>2){ this.clickNum=2 if(this.isWrong){ console.log('答錯'); &n程式設計客棧bsp; this.mask=false this.maskTips=true returnfalse }else{ console.log('答對了'); } } $('.answer-btnNDaLOnvgxW').removeClass('wrong') this.orderTitle=this.orderTitles[this.clickNum] this.isRight=this.mask=false this.title=this.allData.question[this.clickNum].title this.answer=this.allData.question[this.clickNum].answner },1200) } },

以上就是vue實現答題功能的詳細內容,更多關於Vue答題的資料請關注我們其它相關文章!