mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
feat(vue): add ionic vue beta (#22062)
This commit is contained in:
37
packages/vue/src/components/IonTabButton.ts
Normal file
37
packages/vue/src/components/IonTabButton.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { h, defineComponent, inject } from 'vue';
|
||||
|
||||
export const IonTabButton = defineComponent({
|
||||
name: 'IonTabButton',
|
||||
setup(_, { attrs, slots }) {
|
||||
const ionRouter: any = inject('navManager');
|
||||
const onClick = (ev: Event) => {
|
||||
|
||||
if (ev.cancelable) {
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
||||
const { tab, href } = attrs;
|
||||
const currentRoute = ionRouter.getCurrentRouteInfo();
|
||||
|
||||
if (currentRoute.tab === tab) {
|
||||
if (href !== currentRoute.pathname) {
|
||||
ionRouter.resetTab(tab, href);
|
||||
}
|
||||
} else {
|
||||
// TODO tabs will change/did change
|
||||
ionRouter.changeTab(tab, href)
|
||||
}
|
||||
}
|
||||
return () => {
|
||||
const children = slots.default && slots.default()
|
||||
return h(
|
||||
'ion-tab-button',
|
||||
{
|
||||
onClick,
|
||||
...attrs
|
||||
},
|
||||
children
|
||||
)
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user