Ionic framework Tabbar不隐藏在Ionic 5的子页面上
在ionic 4或5中,tabbar不隐藏在子页面上。 当然,它在离子2或离子3中工作良好。 请告诉我如何解决这个问题。这是我的解决方案。 但希望是最好的解决办法Ionic framework Tabbar不隐藏在Ionic 5的子页面上,ionic-framework,hide,tabbar,Ionic Framework,Hide,Tabbar,在ionic 4或5中,tabbar不隐藏在子页面上。 当然,它在离子2或离子3中工作良好。 请告诉我如何解决这个问题。这是我的解决方案。 但希望是最好的解决办法 创建选项卡服务 在app.module.ts中导入此 以下是选项卡服务的完整代码 import { Injectable } from '@angular/core'; import { filter } from 'rxjs/operators'; import { NavigationEnd, Router } from '@an
import { Injectable } from '@angular/core';
import { filter } from 'rxjs/operators';
import { NavigationEnd, Router } from '@angular/router';
import { Platform } from '@ionic/angular';
@Injectable({
providedIn: 'root'
})
export class TabsService {
constructor(private router: Router, private platform: Platform) {
this.platform.ready().then(() => {
this.navEvents();
});
}
public hideTabs() {
const tabBar = document.getElementById('kidesiaTabBar');
if (tabBar && tabBar.style.display !== 'none') {
tabBar.style.display = 'none';
}
}
public showTabs() {
const tabBar = document.getElementById('kidesiaTabBar');
if (tabBar && tabBar.style.display !== 'flex') {
tabBar.style.display = 'flex';
}
}
private navEvents() {
this.router.events
.pipe(filter(e => e instanceof NavigationEnd))
.subscribe((e: any) => {
this.showHideTabs(e);
});
}
private showHideTabs(e: any) {
const urlArray = e.url.split('/');
if (urlArray.length >= 3) {
let shouldHide = true;
if (urlArray.length === 3 && urlArray[1] === 'tabs') {
shouldHide = false;
}
try {
setTimeout(() => (shouldHide ? this.hideTabs() : this.showTabs()), 300);
} catch (err) {}
}
}
}