Answer the question
In order to leave comments, you need to log in
Can Vue use setTimeout in a template?
:class="!$store.state.isOverlay ? 'scroll-y' : ''
Is it possible to somehow set setTimeout to class bind, so that, for example, it only works in a second?
Answer the question
In order to leave comments, you need to log in
setTimeout returns the id of the timer. Thus, using it in a template, you will immediately get a true-like value. And the class will hang.
Make the class appear depending on the value of the property in data, by default the property is false, and in the mounted setTimout, in which you change this property to true - the class will be updated.
Documentation example: Working with classes and styles
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question