Answer the question
In order to leave comments, you need to log in
How to access specific elements on a page in Vue.js?
Good afternoon, tell me please.
If in js I could assign another class to the example class by doing:<div class="example">Привет</div>
let dot = document.getElementsByClassName('dot');
dot.classList.add('example2');
dot.style.display = 'none',
Answer the question
In order to leave comments, you need to log in
When you write in view, you must be aware of the state of the data. Roughly speaking, the imperative approach here is not entirely in the subject.
You don't have to write "assign class on click"
Instead you should do this
data() {
return {
isShowHelloBlock: false,
}
}
<div :class="{someClass : isShowHelloBlock}">Hello</div>
<button @click="isShowHelloBlock = true">toggle block</button>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question