HashLocationStrategy中的angular2缺少查询字符串 [英] angular2 missing query string in HashLocationStrategy

查看:119
本文介绍了HashLocationStrategy中的angular2缺少查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用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路由:路由= [{小路: '',redirectTo:'/dashboard',pathMatch:已满"},{路径:仪表板",组件: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#/???

解决方案

我现在知道我的错误.

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

@GünterZöchbauer

非常感谢

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

when I use PathLocationStrategy, http://localhost:3000/dashboard/123?cc=1111 works fine.

when I use HashLocationStrategy, visit http://localhost:3000/?cc=1111#/dashboard/123 the url always redirect to http://localhost:3000/#/dashboard/123, and miss the query string ?cc=1111

my demo code repo https://github.com/jinceon/routebug

==========updated===========

I know my mistake now.

the url I visit is http://localhost:3000/?cc=1111#/dashboard/123

@GünterZöchbauer

thanks very much

the right url is http://localhost:3000/#/dashboard/123?cc=1111

----my another question------

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

when I visit http://localhost:3000/#/?cc=1111, I thought it will redirect to http://localhost:3000/#/dashboard?cc=1111, but it in fact redirect to http://localhost:3000/#/dashboard.

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

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

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

解决方案

I know my mistake now.

the url I visit is http://localhost:3000/?cc=1111#/dashboard/123

@GünterZöchbauer

thanks very much

the right url is http://localhost:3000/#/dashboard/123?cc=1111

这篇关于HashLocationStrategy中的angular2缺少查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆