I’m working with BootstrapVue
.
I have – I think – a very simple question, but I could not find anything that worked for me. I have a <b-button>
which I want to click and than the second <div>
should be shown but only for 3 Seconds.
I want to have my code without jQuery – how can I achieve that?
Thank You!
JavaScript
x
9
1
<div class="row mb-3">
2
<div class="col-8 col-md-6 mt-4 ml-1">
3
<b-button @click="clickIt()"</b-button>
4
</div>
5
<div class="col-2 col-md-5 mt-4">
6
<p>You've clicked it!</p>
7
</div>
8
</div>
9
Advertisement
Answer
I hope this should resolve your problem.
JavaScript
1
23
23
1
<div class="row mb-3">
2
<div class="col-8 col-md-6 mt-4 ml-1">
3
<b-button @click="clickIt()"</b-button>
4
</div>
5
<div v-if="isClicked" class="col-2 col-md-5 mt-4">
6
<p>You've clicked it!</p>
7
</div>
8
</div>
9
10
export default {
11
data: () => {
12
return { isClicked: false };
13
},
14
methods: {
15
clickIt() {
16
this.isClicked = true
17
setTimeout(() => {
18
this.isClicked = false;
19
}, 3000);
20
},
21
},
22
};
23