R
R
reasonov2021-06-13 09:10:16
Vue.js
reasonov, 2021-06-13 09:10:16

How to define multiple dynamic classes?

Hello, I can’t find the answer to my question, there is a task to set two classes at the same time like this:

:class="class + number, classss + number: page === 2"

If I try to check :class="{{ classss + number : page === 2 }}", then it swears at +, I put it in computed, tried to write something like this:

:class="computedClass, class + number" swears at a comma in this case..

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aetae, 2021-06-13
@reasonov

Maybe you should read the documentation ?
Preferably all. Everything is very clear and there is not much text.

W
WapSter, 2021-06-13
@wapster92

Why do you need two brackets there? You pass an object there, so talk to it like an object, where the key is the class name and the value is a boolean variable.

<div class="box" :class="{ classOne: switcher, classTwo: switcher }"></div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question