I’m having an issue with Ionic 5 + Vue trying to create dynamic tabs. Hardcoded tabs work fine.
<ion-tabs>
<ion-tab-bar slot="bottom" class="ion-hide-md-up">
<ion-tab-button tab="home" href="/home" :selected="currentPath == '/home'">
<ion-icon :icon="home" />
<ion-label>Home</ion-label>
</ion-tab-button>
<ion-tab-button tab="about" href="/about" :selected="currentPath == '/about'">
<ion-icon :icon="information-outline" />
<ion-label>About</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
However dynamically creating tabs has an issue when changing the tab.
<ion-tabs>
<ion-tab-bar slot="bottom" class="ion-hide-md-up">
<ion-tab-button :tab="tab.key" :href="tab.path" :selected="currentPath == tab.path" :key="tab.key" v-for="tab in tabs">
<ion-icon :icon="tab.icon"></ion-icon>
<ion-label>{{tab.label}}</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
data() {
return {
tabs: [
{
key: "home",
label: "Home",
path: "/home",
icon: home
},
{
key: "about",
label: "About",
path: "/about",
icon: informationOutline
}
]
}
}
The error is Cannot read property ‘home’ of undefined at onClick.
Is this an Ionic bug? Or did I do something wrong defining my dynamic tabs?