0👍
Try this:
<div
v-for="tab in tabs"
:key='tab'
@click="currentTab = tab"
:class="['tab-button', {active: currentTab === tab}]"
>
<font-awesome-icon >
icon="user-secret"
</font-awesome-icon >
</div>
also this @click="currentTab = tab"
needs to be refactored
- [Vuejs]-Vue get children of a component passed in a parent component
- [Vuejs]-How to change the mail settings while using queue in laravel to send mail and notification
0👍
I’ll assume that this issue has already been solved, but, in any case, here is my contribuition using fontAwesome so you can understand the logic:
Change the definition of your data tabs
and currentTab
to something like this:
currentTab: {title:'Post section',icon:'bell',page:'Post'},
tabs:{
title:'Post section',
icon:'bell',
page:'Post'
},
{
title:'List of posts',
icon:'list',
page:'List'
}
Convert your font-awesome-icon
tag to:
<button v-for="tab in tabs" :key="tab"
:class="['tab-button', { active: currentTab === tab }]" @click="currentTab = tab"
title="tab.title">
<i class="fa" :class="'fa-'+tab.icon"></i>
</button>
Finally change you component
tag to:
<component :is="currentTab.page" class="tab"></component>
And them you can ignore the whole compuded: {}
section of your export default
- [Vuejs]-How can I populate nested different content inside v-for loop
- [Vuejs]-How to get the data from a dynamically generated form in VUE?
Source:stackexchange.com