D
D
dmitry20002021-09-08 16:16:16
Vue.js
dmitry2000, 2021-09-08 16:16:16

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

1 answer(s)
V
Vadim, 2021-09-08
@dmitry2000

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 question

Ask a Question

731 491 924 answers to any question