angular - Ionic 4/5 - 错误:路由:当标签页用作组件时
问题描述
大家好,当我使用 Tabs 作为组件时,我遇到了路由问题。
我所做的是,我制作了一个标签页和一个 shared.Module.Ts 文件。
在 shared.Module.Ts 文件中,我导入标签页,因为我想在许多页面中使用此标签。Tabs 页面在其他页面中完全导入成功,但我卡在 Routing 中,它给了我一个错误
ERROR 错误:未捕获(在承诺中):错误:无法匹配任何路由。URL 段:“家庭/地址”
请帮帮我这是我的代码
Shared.module.ts 文件
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { TabsPage } from "../pages/tabs/tabs.page";
@NgModule({
declarations: [TabsPage],
exports: [TabsPage],
imports: [CommonModule],
})
export class SharedModule {}
标签页
<ion-tab-bar slot="bottom">
<ion-tab-button tab="home">
<ion-icon name="triangle"></ion-icon>
<ion-label>Tab 1</ion-label>
</ion-tab-button>
<ion-tab-button tab="myaccount">
<ion-icon name="ellipse"></ion-icon>
<ion-label>Tab 2</ion-label>
</ion-tab-button>
<ion-tab-button tab="address">
<ion-icon name="square"></ion-icon>
<ion-label>Tab 3</ion-label>
</ion-tab-button>
</ion-tab-bar>
选项卡路由.module.ts
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { AddressPage } from "../address/address.page";
import { HomePage } from "../home/home.page";
import { MyaccountPage } from "../myaccount/myaccount.page";
import { TabsPage } from "./tabs.page";
const routes: Routes = [
{
path: "tabs",
component: TabsPage,
children: [
{
path: "home",
children: [
{
path: "",
component: HomePage,
},
],
},
{
path: "myaccount",
children: [
{
path: "",
component: MyaccountPage,
},
],
},
{
path: "wallet",
children: [
{
path: "",
component: AddressPage,
},
],
},
{
path: "",
redirectTo: "/tabs/home",
pathMatch: "full",
},
],
},
{
path: "",
redirectTo: "/tabs/home",
pathMatch: "full",
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class TabsPageRoutingModule {}
请帮我。谢谢
解决方案
推荐阅读
- c++ - 无法使用其他 WebSocket 库连接到 Oat++
- google-cloud-platform - 错误:在请求中找不到 jsonl:gs://{bucket_name}/Frist_test.jsonl
- android - Android Hilt 在启动时崩溃
- json - 如何从文件中读取键盘事件?
- mysql - Json vs 文件存储?我如何决定何时值得使用 Azure/Google Storage 之类的持久存储 API 与 mysql 数据库列?
- image - 在 Flutter 中加载大型本地图像的最有效方法
- javascript - 修改一个json文件
- python - 如何在循环中保存和使用先前的迭代?
- mysql - 无法创建基于集合的查询来创建表数据,而不是按程序进行
- multithreading - 使用 reactor-kafka 使用不同的线程从 Kafka 中的消费者组中读取数据