Reputation: 773
I used same approach as here to make something similar but when ever I click on buttons sometimes it happens right away sometimes after 20 clicks....
Here is my code: (Inside .vue file)
<template>
<div class="right-bar" :class="{'hide':!open}">
<div class="header-bar">
<button @click="changeTab(1)" class="hbm" :class="[ activetab === 1 ? 'active' : '' ]">
<i class="fas fa-tachometer-alt"></i>
</button>
<button @click="changeTab(2)" class="hbm" :class="[ activetab === 2 ? 'active' : '' ]">
<i class="fas fa-comments"></i>
</button>
<button @click="changeTab(3)" class="hbm" :class="[ activetab === 3 ? 'active' : '' ]">
<i class="fas fa-bell"></i>
</button>
<button @click="changeTab(4)" class="hbm" :class="[ activetab === 4 ? 'active' : '' ]">
<i class="fas fa-cog"></i>
</button>
<i class="fas rs-btn" :class="[open?'fa-chevron-down':'fa-chevron-up']" @click.prevent="open=!open"></i>
</div>
<div class="content-form">
<div class="form" v-if="activetab === 1">
<slot name="overview"></slot>
</div>
<div class="form" v-if="activetab === 2">
<slot name="messages"></slot>
</div>
<div class="form" v-if="activetab === 3">
<slot name="notifications"></slot>
</div>
<div class="form" v-if="activetab === 4">
<slot name="settings"></slot>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
open: true,
activetab: 1
}
},
methods: {
changeTab(i) {
this.activetab = i;
}
}
};
</script>
Here is a quick video of it: (because as I said some times it happens in few some times in lot clicks)
Both versions are 2.5.17 but I use one with laravel fresh installation.. Also I have installed vuex and lodash... if it means something
Upvotes: 1
Views: 6925
Reputation: 773
Answer in my case was duplication of elements:
My tab element is:
<div class="form" v-if="activetab === 2">
<slot name="messages"></slot>
</div>
and for slot I used:
<div class="form" slot="messages">
</div>
I duplicated same element and caused which caused crashing :D
Upvotes: 3