javascript - Vuejs中如何将css应用到劣等类

标签 javascript html css vue.js

我有一个 html 文件,可以通过 vuejs 中的按钮工作。
v-bind:class 可以用于一个标签,如下所示。
它消失取决于 bool 数据的 bool 值。

<h3 v-bind:class="{active: bool}">{{counter.document}}</h3>

但我的目标是我要根据优等类(Class)的条件出现和消失劣等类(Class)。
我怎样才能正确地做到这一点?非常感谢您的阅读。

<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>

关于javascript - Vuejs中如何将css应用到劣等类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58076076/

相关文章:

javascript - Jquery匹配字符串中的所有单词

html - 悬停父元素应编辑子元素外观 - 不起作用

html - 如何在默认的 Bootstrap 3 表单中添加内联组件?

jquery - 获得新的首创

javascript - Angular Js 中的可滚动下拉菜单

css - 让一个 div 与另一个 div 重叠

css - 为什么边界半径 :200px is not a circle shape in Safari 5/6?

javascript - insidehtml 提交按钮

javascript - 如何在 Firefox 中将透明 PNG 绘制到 Canvas 上?

javascript - 刷新页面而不出现屏幕空白?