【发布时间】:2021-03-18 12:37:41
【问题描述】:
我尝试使用ionic-back-button。当应用程序加载时,我被重定向到帐户页面 core.page.ts。在此页面中,我有两个带有 routerlink 登录和注册的按钮。当我单击 core.page.html 中的登录按钮时,我被重定向到登录页面。后退按钮也会出现。但是,当单击该后退按钮时,除了涟漪效应外,它什么也不做。我不确定为什么。请帮忙。
在我的 app.routing.module.ts 中
const routes: Routes = [
{
path: '',
redirectTo: 'account',
pathMatch: 'full'
},
{
path: 'account',
loadChildren: () => import('./core/core.module').then( m => m.CorePageModule)
}
];
在我的 core.routing.module.ts 中
const routes: Routes = [
{
path: '',
component: CorePage
},
{
path: 'login',
component: LoginComponent
},
{
path: 'register',
component: RegisterComponent
},
];
在我的 core.page.html 中
<div class="button_wrap">
<ion-button color="success" [routerLink]="['/account/register']" expand="block">Sign Up</ion-button>
<ion-button color="light" [routerLink]="['/account/login']" expand="block">Log In</ion-button>
</div>
在我的登录页面中
<ion-header>
<ion-toolbar color="primary">
<ion-buttons slot="start">
<ion-back-button defaultHref="/" icon="chevron-back-outline" text="Back"></ion-back-button>
</ion-buttons>
<ion-title>LOGIN</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<p> login works! </p>
</ion-content>
这里提到了类似的故事,但没有确切的解决方案。
【问题讨论】: