vue考试链接重置(Vue实现答题功能)
类别:编程学习 浏览量:1678
时间:2021-10-23 10:56:24 vue考试链接重置
Vue实现答题功能1、请求答题接口
2、判断用户是否答对,答对的话跳到下一题,答错的话弹窗告诉用户有错题,请重新答题
<li class="active_title"> <span>{{ orderTitle }}</span> </li> <p v-show="toanswer" ref="question">{{ title }}</p> <li class="answer-btns" @click="answerClick($event)"> <span class="answer-btn" :class="`${isRight && item.result == 1?'right':''}`" v-for="item in answer" :data-result='item.result'>{{ item.name }} <i class="iconfont icon-wrong"></i><i v-show="isRight && item.result == 1" class="iconfont icon-right"></i> </span> </li>
getAllData() { this.$axios.get(答题接口).then((res)=>{ if(parseInt(res.data.errCode)>=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) { const tar = e.target, className = e.target.className if(className == "answer-btn") { this.mask = true const result = tar.dataset.result if(result == 1){ // console.log('选对',result); this.isRight = true $(tar).addClass('right') } else { // console.log('选错',result); this.isRight = true this.isWrong = true $(tar).addClass('wrong') setTimeout(() => { this.maskTips = true }, 1200); } setTimeout( () => { this.clickNum ++ if(this.clickNum > 2) { this.clickNum = 2 if(this.isWrong) { console.log('答错'); this.mask = false this.maskTips = true return false } else { console.log('答对了'); } } $('.answer-btn').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答题的资料请关注开心学习网其它相关文章!
您可能感兴趣
- vue-router的安装(详解Vue-Router的安装与使用)
- vue如何excel表格上传功能(Vue + iView实现Excel上传功能的完整代码)
- vue封装组件技巧(浅谈vue中所有的封装方式总结)
- vue封装一个功能函数(vue中利用mqtt服务端实现即时通讯的步骤记录)
- vuejs filter过滤器的使用(Vue过滤器filter实现及应用场景详解)
- 使用vue独立开发组件(vue单文件组件的实现)
- vue调用组件内部的方法(Vue如何实现组件间通信)
- vue中router的具体用法(vue-router中hash模式与history模式的区别)
- vue调用后台接口实现预览(vue实现集成腾讯TIM即时通讯)
- vue源码系列教程(vue使用引用库中的方法附源码)
- vue实现商品详情讲解(京东 Vue3 组件库支持小程序开发的详细流程)
- vue单元测试实例(Vue-Jest 自动化测试基础配置详解)
- vue集成文件上传插件(vue 实现上传组件)
- vue怎么使用element(Vue Element前端应用开发之图标的维护和使用)
- vue引入axios(vue封装axios的几种方法)
- vue怎么更换自定义水印(Vue之全局水印的实现示例)
- 爱情可以当饭吃吗(怎么回复)
- 高考数学题(高考数学题基础题占多少分)
- 没钱只能吃土(没钱要吃土了幽默短信发朋友圈)
- 今年考高会很难吗(今年高考会考试吗)
- 盘古开天地 他创造了世界,谁创造了盘古 盘古是伏羲吗(盘古开天地他创造了世界)
- 关于队徽 你了解这些么 二(关于队徽你了解这些么)
热门推荐
- dede数据库详解(Dede 删除文档同时文章中的图片的方法)
- sqlserver 高级查询(利用 SQL Server 过滤索引提高查询语句的性能分析)
- laravel 数据表格(Laravel自定义 封装便捷返回Json数据格式的引用方法)
- python高德地图可视化(利用python和百度地图API实现数据地图标注的方法)
- dedecms标签怎么用(dedecms列表页上一页下一页翻页单独调用的方法)
- docker节点不能启动(解决docker中ifconfig不可用的问题)
- C# Directory类的操作
- ie浏览器css颜色兼容(IE8的css hack9 使用说明)
- python开启线程池(对python:threading.Thread类的使用方法详解)
- sqlserver分组查询(sql server如何利用开窗函数over进行分组统计)