I use v-tabs and I want to know: how can i know about tab id, when I change a tab? this is my code:
<v-tabs class="tabs-container" color="green" grow>
<v-tab class="tab"
v-for="tab of tabs"
:key="tab.id"
:title=tab>
{{tab.name}}
</v-tab>
<v-tabs-items>
<v-tab-item v-for="tab in tabs" :key="tab.id">
<div v-if='tab.id == 0'>
<CreateHero v-on:updateAllTabs="updateAllTabs"/>
</div>
<div v-else>
<HeroPresenter/>
</div>
</v-tab-item>
</v-tabs-items>
</v-tabs>
...
methods: {
updateAllTabs() {
axios.get('/hero').then(responce => {
this.tabs = responce.data
})
},
getHero(id) {
this.$emit("getCurrentHero", id);
}
}
so, when a click to tab, I want to send tab id in the HeroPresenter component. I tried to use $emit, but what should I write in v-tab?? My vue-component HeroPresenter was subscribed on "getCurrentHero"
You can add a click event, which will call your function
<v-tab class="tab"
v-for="tab of tabs"
:key="tab.id"
:title=tab
@click="getHero(tab.id)"
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With