4

这些是我的路线:

const routes:Routes =[
  {path:'', component:WelcomeComponent},
  {path:'profile', component: ProfileComponent},
  {path:'addcourse', component: AddcourseComponent},
  {path:'course', component: CourseComponent},
  {path:'editCourse', component: EditCourseComponent},
  {path:'addLectures', component: AddLectureComponent},
  {path:'login', component:LoginComponent},
  {path:'register', component:RegisterComponent},
  // { path: 'newform', canActivate:[AuthGuard], component:NewFomComponent},
  { path: '**', redirectTo:'', pathMatch:'full'}

我的应用程序从欢迎页面开始,当我点击登录时,它会将我带到课程页面,点击课程后,应用程序应该将我带到课程组件​​,但它会重定向到欢迎页面,当我点击登录时,它会给我这个错误:

ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'http://%28login%29/' cannot be created in a document with origin 'http://localhost:4200' and URL 'http://localhost:4200/'.
Error: Failed to execute 'pushState' on 'History': A history state object with URL 'http://%28login%29/' cannot be created in a document with origin 'http://localhost:4200' and URL 'http://localhost:4200/'.

我查找了类似的问题,所有这些问题都建议检查基本 href,在我的应用程序中它设置为 / 所以那里没有问题。谁能请我做错了什么?

4

1 回答 1

0

尝试在路线上添加斜杠:

<a mat-list-item routerLink="/profile" routerLinkActive>Profile</a>
于 2020-02-10T14:11:57.287 回答