我有一个ion-tab与型动物的方式来重定向:通过在路线tabs.module.ts,并通过[routerLink]在HTML中。
问题是:当ion-tab-buttons点击它们时,它们可以正确导航到其他页面,但颜色仅在使用路由和“loadchildren”路由时才会改变。
使用 CSS:
ion-tab-button {
--color-selected: var(--ion-color-text-secondary);
}
Run Code Online (Sandbox Code Playgroud)
我尝试loadChildren在所有选项卡中使用路由,但有些选项卡要重定向到组件并且没有成功。我还尝试在 CSS 中使用伪类,例如
ion-tab-button:active {
color: blue;
}
Run Code Online (Sandbox Code Playgroud)
实际文件:
标签页.html
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button tab="home">
<i class="fal fa-home-alt fa-2x"></i>
</ion-tab-button>
<ion-tab-button [routerLink]="['/tabs/home/feed/feed-user/' + id]">
<i class="fal fa-user-circle fa-2x"></i>
</ion-tab-button>
<ion-tab-button [routerLink]="['/tabs/home/trade-room']">
<i class="fal fa-comments-alt-dollar fa-2x"></i>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
Run Code Online (Sandbox Code Playgroud)
tabs.module.ts
const routes: Routes = [
{
path: '',
component: TabsPage,
children: [
{
path: '',
redirectTo: '/tabs/home',
pathMatch: 'full'
},
{
path: …Run Code Online (Sandbox Code Playgroud)