Kay Singian
Kay Singian

Reputation: 1381

VueJS conditional class appended to mandatory class

Not sure how to do this, I remember reading something like the syntax below to make the appended "disabled" string conditional in the class. "form-control" should not be ommitted.

<input type="text" :class="{'form-control ':true}, {'disabled' : edit===true}">

Upvotes: 3

Views: 951

Answers (1)

raina77ow
raina77ow

Reputation: 106385

You can just mix two of those (static and dynamic classes), according to VueJS docs:

In addition, the v-bind:class directive can also co-exist with the plain class attribute.

<input type="text" class="form-control" :class="{disabled: edit}">

Upvotes: 4

Related Questions