1

I have a html file that works by button in vuejs.
The v-bind:class can be used for one tag like below.
It dissapears depends on the boolean of bool data.

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

But my goal is I want to appear and dissapear the inferior class depends on the superior class condition.
How can I make it correctly? Thank you so much for reading.

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

1 Answer 1

1

Use condition in 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>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.