mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
chore(): fix tabs (#19821)
* fix(tabs): do not wait on child tab setActive() lazy loading * whenDefined example * chore(): fix lint
This commit is contained in:
@ -46,7 +46,9 @@ export class Tabs implements NavOutlet {
|
||||
}
|
||||
if (!this.useRouter) {
|
||||
const tabs = this.tabs;
|
||||
await this.select(tabs[0]);
|
||||
if (tabs.length > 0) {
|
||||
await this.select(tabs[0]);
|
||||
}
|
||||
}
|
||||
this.ionNavWillLoad.emit();
|
||||
}
|
||||
@ -127,7 +129,8 @@ export class Tabs implements NavOutlet {
|
||||
this.leavingTab = this.selectedTab;
|
||||
this.selectedTab = selectedTab;
|
||||
this.ionTabsWillChange.emit({ tab: selectedTab.tab });
|
||||
return selectedTab.setActive();
|
||||
selectedTab.active = true;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private tabSwitch() {
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
|
||||
</head>
|
||||
|
||||
<body onload="selectTab()">
|
||||
<body>
|
||||
<ion-tabs>
|
||||
<ion-tab tab="tab-one">
|
||||
<div class="content-div div-one">
|
||||
@ -71,11 +71,11 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
async function selectTab() {
|
||||
customElements.whenDefined('ion-tabs').then(async () => {
|
||||
const tabs = document.querySelector('ion-tabs');
|
||||
await tabs.componentOnReady();
|
||||
await tabs.select('tab-three');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user