Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度路由器总是将我重定向到/#/_Angular_Angular Ui Router - Fatal编程技术网

Angular 角度路由器总是将我重定向到/#/

Angular 角度路由器总是将我重定向到/#/,angular,angular-ui-router,Angular,Angular Ui Router,我有这个问题,我在stackoverflow中搜索了它,但没有结果,当应用程序启动时,链接在127.0.0.1:4200/#/之后变为127.0.0.1:4200 我认为问题出在我的环境中,所以我将其上传到heroku,但仍然是同一个问题 在正常情况下,我的路线是: const AppRoutes:Routes=[ {path:'',component:IndexPageComponent}, {path:'Login',component:LoginRegist

我有这个问题,我在stackoverflow中搜索了它,但没有结果,当应用程序启动时,链接在127.0.0.1:4200/#/之后变为127.0.0.1:4200

我认为问题出在我的环境中,所以我将其上传到heroku,但仍然是同一个问题

在正常情况下,我的路线是:

    const AppRoutes:Routes=[
      {path:'',component:IndexPageComponent},
      {path:'Login',component:LoginRegisterComponent},
      {path:'Services',component:ServicesComponent},
      {path:'ContactUs',component:ContactComponent},
      {path:'AboutUs',component:AboutUsComponent},
    ]

在Angular中,有两种方法(或Angular称之为策略)来解析链接

PathLocationStrategyHashLocationStrategy了解更多详细信息,请阅读

要启用一个,您只需要首先从@angular/common导入它,并告诉angular以这种方式使用它

providers: [
    {provide: LocationStrategy,useClass:PathLocationStrategy}]


在根routermodule配置中,您应该能够使用fine
useHash
字段,如果您删除它,那么每次都应该按照预期工作,如果没有您提供的,它将默认出现