HashLocationStrategy中的angular2缺少查询字符串

时间:2017-02-15 09:45:19

标签: angular

当我使用PathLocationStrategy时, http://localhost:3000/dashboard/123?cc=1111工作正常。

当我使用HashLocationStrategy时,请访问http://localhost:3000/?cc=1111#/dashboard/123 该网址始终重定向到http://localhost:3000/#/dashboard/123,并且错过了查询字符串?cc=1111

我的演示代码仓库https://github.com/jinceon/routebug

==========更新===========

我现在知道我的错误。

我访问的网址是http://localhost:3000/?cc=1111#/dashboard/123

@GünterZöchbauer

非常感谢

正确的网址是http://localhost:3000/#/dashboard/123?cc=1111

----我的另一个问题------

const routes: Routes = [
  {
    path: '',
    redirectTo: '/dashboard',
    pathMatch: 'full'
  },
  {
    path: 'dashboard',
    component: DashboardComponent
  }
]

当我访问http://localhost:3000/#/?cc=1111时,我认为它会重定向到http://localhost:3000/#/dashboard?cc=1111,但实际上会重定向到http://localhost:3000/#/dashboard

http://localhost:3000/?cc=1111

http://localhost:3000/#/?cc=1111

http://localhost:3000/?cc=1111#/ ???

1 个答案:

答案 0 :(得分:0)

我现在知道我的错误。

我访问的网址是http://localhost:3000/?cc=1111#/dashboard/123

@GünterZöchbauer

非常感谢

正确的网址是 http://localhost:3000/#/dashboard/123?cc=1111

相关问题