S
S
Sector5672020-07-07 19:47:02
Vue.js
Sector567, 2020-07-07 19:47:02

How to implement such logic in vue without document.querySelector?

How to get rid of document.querySelector, which everyone swears about in vue, but at the same time so that the logic is preserved?
Here is the code
https://codepen.io/Crot/pen/wvMmjZm

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2020-07-07
@Sector567

Add styles:

.child.red {
  background: red;
}

Let the click handler look like this: @click="n.em = !n.em".
And the class assignment is as follows: :class="{ red: n.em }".

V
Vladimir Korotenko, 2020-07-07
@firedragon

Correctly swear. Make a control that changes the state of the isOn variable further in the style, use a conditional operator, it is in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question