嗨,在我的应用程序中,如果我刷新它会转到主页,我需要避免这种情况并希望重定向到特定的所需路径,无法找到在路由或某处实现此功能的位置,任何人都可以帮助我。我的 app.component 文件
import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute, Params} from "@angular/router";
import {AppService} from "../../services/app.service";
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
islogin: boolean = true;
currentPage: string = '';
constructor(
private router: Router,
public appService: AppService
) {
}
ngOnInit() {
this.islogin = !this.islogin;
}
}
路由文件:
export const appRoutes: Routes = [
{
path: 'login',
component: LoginComponent
},
{
path: 'superuser-miscsuperusers',
component: miscsuperusersComponent
},
{
path: '**',
component: LoginComponent
},
{
path: 'clients',
component: ClientsComponent
}
];
export const appRoutingProviders: any[] = [];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes/*, { enableTracing: true }*/);