class根据状态 vue_vue单选题 如何把v-bind:class两个状态同时显示出来呢?

本文介绍如何在Vue中处理单选题,同时显示答案的正确和错误状态。通过示例代码展示了如何根据用户选择更新元素的class,以呈现不同的边界样式。
摘要由CSDN通过智能技术生成

自己写的效果样子

c3550ec07ae3fb9e83b0f8fd4f0b3fcf.png

故意点错误的答案,再点提交之后 效果图

051c52530254aa375cb49c7f8e58e755.png

我现在不会弄两个class

怎么判断答案和选中的

然后分别把两个正确状态和错误状态一并显示出来

//不知道为什么大家好像没有看到demo给的链接,我就甩出下面的代码来。

Document

* {

margin: 0;

padding: 0;

}

.scroll-wrap {

width: 200px;

border: 1px solid blue;

overflow: hidden;

}

.scroll-content {

position: relative;

transition: top 0.5s;

}

.scroll-content li {

line-height: 50px;

text-align: center;

}

.active {

border: 1px solid #ddd;

}

.Right{

border:1px solid red;

}

.Error{

border:1px solid #4ac291;

}

【{{duoxuan[types-1]}}】

剩余答题时间:

60

{{titleexam}}

/>{{item.answer}}

{{item.answer}}

{{item}}

提交

var result = { "code": 100, "message": "操作成功", "data": { "isRight": 0, "answer": [{ "score": 0, "answer": "悲观厌世", "id": 27749 }, { "score": 0, "answer": "出现幻觉、妄想", "id": 27750 }, { "score": 0, "answer": "有自杀企图或行为", "id": 27751 }, { "score": 1, "answer": "兴趣狭窄", "id": 27752 }], "id": 127, "title": "自闭症患者主要表现为不同程度的言语发育障碍、人际交往障碍、行为方式刻板和( )几方面。", "type": 1 } }

new Vue({

el: "#example",

data: {

answer: '',

duoxuan: ['单选题', '多选题', '判断题'],

rightlist: ['正确', '错误'],

types: '',

titleexam: '',

examId: '',

checkQues: {},

},

created: function () {

var self = this;

console.log(result.data);

self.titleexam = result.data.title;

self.answer = result.data.answer;

self.types = result.data.type;

self.examId = result.data.id;

self.types = result.data.type;

},

methods: {

alocked: function (item, check, id, pageid) { //单选题

this.checkQues[id] = '' + check + ''; //已答题的区集

},

checkeds: function (items, check, id, pageid) { //多选题

var checkListDate = this.checkList;

var check = check.toString();

if (this.checkList.indexOf(check) > -1) {

let index = this.checkList.indexOf(check)

this.checkList.splice(index, 1)

var duoid = this.checkList.join();

if (duoid == "") {

}

this.checkQues[id] = '' + duoid + ''; //已答题的区集

} else {

this.checkList.push(check);

var duoid = this.checkList.join();

this.checkQues[id] = '' + duoid + ''; //已答题的区集

}

},

judgment: function (item, check, pageid) { //判断题

if (item == 0) {

this.checkQues[pageid] = 1; //已答题的区集

} else {

this.checkQues[pageid] = 0; //已答题的区集

}

},

}

})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值