我正在尝试从用户写下的未知路径重定向到自定义404页面:
例如:
/ login转到登录页面
/ main转到主页
{unknown-path}转到404
export const deepLinkConfig: DeepLinkConfig = {
links: [
{ component: HomePage, name: "Home", segment: "" },
{ component: LoginPage, name: "Login", segment: "login", defaultHistory: [HomePage] },
{ component: SubscribePage, name: "Signup", segment: "signup", defaultHistory: [HomePage] },
{ component: SubscribeExtendPage, name: "Signup", segment: "signup-extend", defaultHistory: [HomePage] },
{ component: MainPage, name: "Main", segment: "main", defaultHistory: [HomePage] },
{ component: WelcomePage, name: "Welcome", segment: "welcome" },
{ component: NotFoundPage, name: "notFound", segment: "login/**", defaultHistory: [NotFoundPage] },
]
};
imports: [
BrowserModule,
HttpClientModule,
MaterializeModule,
BrowserAnimationsModule,
IonicModule.forRoot(MyApp, {}, deepLinkConfig)
],
感谢您的帮助。
答案 0 :(得分:2)
{ component: NotFoundPage, name: "*", segment: ":**", defaultHistory: [NotFoundPage] },
我不知道它是否是最佳解决方案,但最终使用任何类型的变量设置了段:**现在所有未知的url都被重定向到NotFoundPage。