[英]Vue.js - Add Class on Click Event
I would like to dynamically toggle a class on a click
event on a div in Vue.js without using properties/data to do so. 我想动态切换Vue.js中div上的
click
事件的类,而不使用属性/数据来执行此操作。
Here is my div 这是我的div
<div class="quiz-item" @click="checkAnswer(1)">
When this div
is clicked, I would like to add the class quiz-item--correct
or quiz-item--incorrect
(the logic for this will be handled elsewhere). 单击此
div
,我想添加类quiz-item--correct
或quiz-item--incorrect
(此逻辑将在其他地方处理)。 I cannot use properties as there are too many answers in the quiz for it to be a maintainable/viable approach. 我无法使用属性,因为测验中有太多答案,因为它是一种可维护/可行的方法。
Does anyone have any ideas on how I can achieve this functionality? 有没有人对如何实现这一功能有任何想法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.