Answer the question
In order to leave comments, you need to log in
How to set a tag class after a certain time?
Good day.
There is this code:
<template>
<div>
<span class="b-span"
// v-bind:class="{ 'b-span_active' }" ???
>
</span>
</div>
</template>
<script>
export default {
name: 'name',
data () {
return {
dataTime: '300',
}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
<span class="b-span" :class="{ 'b-span_active': active }">hello, world!!</span>
<button @click="onClick">click me</button>
data: () => ({
active: false,
time: 300,
}),
methods: {
onClick() {
setTimeout(() => this.active = true, this.time);
},
},
Create a handler for
some click
function () {
setTimeout(300, () => {
var span = document.querySelector('.b-span') // либо селектор по id
span.classList.add('b-span_active')
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question