【问题标题】:Uncaught (in promise): SecurityError: Failed to execute 'pushState' on 'History'未捕获(承诺):SecurityError:无法在“历史”上执行“pushState”
【发布时间】:2018-05-06 13:02:23
【问题描述】:

这些是我的路线:

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,在我的应用程序中它设置为 / 所以那里没有问题。谁能请我做错了什么?

【问题讨论】:

    标签: javascript angular typescript angular4-router


    【解决方案1】:

    尝试在路由上添加斜线:

    <a mat-list-item routerLink="/profile" routerLinkActive>Profile</a>
    

    【讨论】:

      猜你喜欢
      • 2018-03-06
      • 2019-09-16
      • 2018-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多