vue.js - 如何在 v-if Vue.js 中添加类
问题描述
如果状态为非活动,我想以红色突出显示文本。下面是我的代码
<td v-for="option in selected_type" v-if="option.id == item.status" v-bind:class="add class here">
@{{ option.status }}
</td>
谢谢
解决方案
<td v-for="option in selected_type" :key="option.id" :class="{ inactive: item.status }">
我假设状态属性是一个布尔值(不知道你为什么还要将 id 与状态进行比较)
.inactive { color: red; }
推荐阅读
- c - 调用 mremap(2) 时出现奇怪的信号处理程序行为
- python - 如何使用大型 MS COCO 数据集在 Tensorflow 中训练模型以进行多类目标检测?
- flutter - 通过 Flutter for Firebase 重新发送验证
- python - 从 txt 文件 Python 3.x 帮助的列表中复制元素 :(
- javascript - 如何让 vue-progressbar 显示?
- google-apis-explorer - Youtube googleapis.com/youtube/v3/channels 今天停止为我工作
- ios - 将类对象传递给另一个类错误
- r - is.error() 找不到功能什么是 Rpackage:R 异常处理
- r - 数据集 %>% rename(!!vars) 在 R 中是什么意思?
- php - php for循环中的html表单-编辑/删除按钮