相关疑难解决方法(0)

Angular 5 - 在浏览器刷新时将页面重定向到主页

目前,当我从路线刷新页面时

HTTP://本地主机:4200 /反馈

它停留在同一条路线上.但我希望路由重定向到

HTTP://本地主机:4200

我看到有人问过如何实现刷新以保持同一条路线.所以我猜,默认角度应该在浏览器刷新时重定向到主页.知道为什么我的角度默认项目会这样做吗?

下面是我的AppRoutingModule

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { SmileyFeedbackComponent } from '../smiley-feedback/smiley-feedback.component';
import { FeedbackFormComponent } from '../feedback-form/feedback-form.component';
import { ThankYouComponent } from '../thank-you/thank-you.component';

const routes: Routes = [
  { path: '', redirectTo: '/smiley', pathMatch: 'full' },
  { path: 'smiley', component: SmileyFeedbackComponent },
  { path: 'feedback', component: FeedbackFormComponent },
  { path: 'thank-you', component: ThankYouComponent }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes)
  ],
  exports: [ RouterModule ],
  declarations: …
Run Code Online (Sandbox Code Playgroud)

typescript angularjs-ng-route angular

21
推荐指数
2
解决办法
5万
查看次数

标签 统计

angular ×1

angularjs-ng-route ×1

typescript ×1