首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ion-tab选项卡属性与ion-fab routerLink的不同行为

ion-tab选项卡属性与ion-fab routerLink的不同行为
EN

Stack Overflow用户
提问于 2022-01-11 19:51:27
回答 1查看 435关注 0票数 2

我有一个离子标签页包含事件特定的信息要显示。路由设置为将您路由到特定事件的选项卡页

tabs.page.html

代码语言:javascript
复制
<ion-tabs>
    <ion-tab-bar slot="bottom" mode="md">
        <ion-tab-button tab="token">
            <ion-icon src="/assets/svg/ticket-star.svg"></ion-icon>
            <ion-label>Tokens</ion-label>
        </ion-tab-button>

        <ion-tab-button tab="transactions">
            <ion-icon src="/assets/svg/empty-wallet-change.svg"></ion-icon>
            <ion-label>Transactions</ion-label>
        </ion-tab-button>

        <div class="centerd-btn"></div>

        <ion-tab-button tab="swipe">
            <ion-icon src="/assets/svg/people.svg"></ion-icon>
            <ion-label>Swipe</ion-label>
        </ion-tab-button>

        <ion-tab-button tab="buy">
            <ion-icon src="/assets/svg/card.svg"></ion-icon>
            <ion-label>Buy</ion-label>
        </ion-tab-button>

        <ion-tab-button tab="user" hidden>
        </ion-tab-button>

        <ion-tab-button tab="notifications" hidden>
        </ion-tab-button>

        <ion-tab-button tab="help" hidden>
        </ion-tab-button>

    </ion-tab-bar>
    <ion-fab vertical="bottom" horizontal="center" slot="fixed">
        <ion-fab-button routerLink="scan" routerLinkActive="active-tab" [routerLinkActiveOptions]="{exact:true}">
            <ion-icon src="/assets/svg/qr-scan.svg"></ion-icon>
        </ion-fab-button>
        <ion-label>Scan at bar</ion-label>
    </ion-fab>
</ion-tabs>

tabs-routing.module.ts

代码语言:javascript
复制
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TabsPage } from './tabs.page';

const routes: Routes = [
  {
    path: ':eventId',
    component: TabsPage,
    children: [
      {
        path: 'home',
        loadChildren: () => import('../home/home.module').then(m => m.HomePageModule)
      },
      {
        path: 'token',
        loadChildren: () => import('../token/token.module').then(m => m.TokenPageModule)
      },
      {
        path: 'transactions',
        loadChildren: () => import('../transactions/transactions.module').then(m => m.TransactionsPageModule)
      },
      {
        path: 'swipe',
        loadChildren: () => import('../swipe/swipe.module').then(m => m.SwipePageModule)
      },
      {
        path: 'buy',
        loadChildren: () => import('../buy/buy.module').then(m => m.BuyPageModule)
      },
      {
        path: 'scan',
        loadChildren: () => import('../scan/scan.module').then(m => m.ScanPageModule)
      },
      {
        path: 'notifications',
        loadChildren: () => import('../notifications/notifications.module').then(m => m.NotificationsPageModule)
      },
      {
        path: 'help',
        loadChildren: () => import('../help/help.module').then(m => m.HelpPageModule)
      },
      {
        path: 'user',
        loadChildren: () => import('../user/user.module').then(m => m.UserPageModule)
      },
      {
        path: '',
        redirectTo: '/event/swipedrinks/home',
        pathMatch: 'full'
      }
    ]
  },
  {
    path: '',
    component: TabsPage
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class TabsPageRoutingModule {}

除了这个<ion-fab>元素的路由之外,所有操作都很好。我可以在第一次点击它,应用程序被正确地路由到例如/event/A4OUJTpgYfeNEF6e5k4v/scan,但是在单击另一个选项卡元素之后,您就不能返回到扫描部分。

我没有任何控制台错误,所以我不知道从哪里开始。

我猜Ionic正在处理tab属性,与ion-fab元素中的routerLink属性不一样,但是有什么可供选择的呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-27 07:16:25

嗨,似乎有一些问题在溶胶离子面对同样的问题在侧导航解决了问题通过使用(click)="navController.naviagteForward('event/scan')“和构造函数(公共导航控制器:NavController)

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70672632

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档