在Angular 2中base href区分大小写 [英] base href is case sensitive in Angular 2

查看:64
本文介绍了在Angular 2中base href区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Angular 2应用设置了这样的基本引用

I have set the base ref like this for an Angular 2 app

<base href="MyApp"/>

如果我转到localhost/MyApp,则一切正常.但是,如果我转到localhost/myapp,则无法识别该路由.如何告诉Angular将基本路由视为不区分大小写?

If I go to localhost/MyApp everything works correctly. However, if I go to localhost/myapp the route is not recognised. How can I tell Angular to treat the base route as case insensitive?

推荐答案

您将必须编写代码以覆盖基本href.

You will have to write code to override base href.

您可以覆盖的可能位置是 1. Angular2:使路由路径不区分大小写

Possible locations you can override is 1. Angular2: Make route paths case insensitive

  1. 您编写自己的位置策略&忽略大小写敏感. 在您的app.module.ts中,您告诉Angular 2应用在提供程序部分使用自定义位置策略.

  1. You write your own location strategy & Ignore case sensitivity there. And in your app.module.ts, you tell ur Angular 2 app to use custom location strategy in your providers section.

{provide:LocationStrategy,useClass:CustomPlatformLocation},

{provide:LocationStrategy,useClass:CustomPlatformLocation},

这篇关于在Angular 2中base href区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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