javascript - Vuejs中如何将css应用到劣等类
问题描述
我有一个 html 文件,可以通过 vuejs 中的按钮工作。
v-bind:class 可用于一个标签,如下所示。
它消失取决于布尔数据的布尔值。
<h3 v-bind:class="{active: bool}">{{counter.document}}</h3>
但我的目标是我想出现和消失下等阶级取决于上等阶级的条件。
我怎样才能正确地做到这一点?非常感谢您的阅读。
<div v-bind:class="{active: orderOptions.item.document}">
<button v-on:click="counter.document -= 1">-</button>
<h3>{{counter.document}}</h3>
<button v-on:click="counter.document += 1">+</button>
</div>
解决方案
V-bind:style
VueJS中的使用条件:
v-bind:style= "[condition ? {styleA} : {styleB}]"
<div v-bind:style="[orderOptions.item.document ?"active",""]">
<button v-on:click="counter.document -= 1">-</button>
<h3>{{counter.document}}</h3>
<button v-on:click="counter.document += 1">+</button>
</div>
推荐阅读
- c# - 如何从用户控件访问其子窗体?
- python - 终端应用程序在第一次输入后退出程序。需要帮助测试 Python '猜数字游戏'
- java - K-means 聚类算法中的收敛条件是什么?
- physics - 薛定谔与散射最大
- java - 无法读取 Firebase 数据库,数据返回 null
- php - 如果产品标题包含现有的“品牌”,则添加为属性 - Woocommerce
- static - 如何更新本地存储的 GTFS 静态数据
- c# - 是否可以复制 JsonObjectAttribute 的行为?
- azure - 使用 CLI 为服务应用创建 Azure 服务主体
- python - 从另一个函数 python 访问列表只是一个列表,如下图所示