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

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

问题描述

我已经为 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?

推荐答案

您将不得不编写代码来覆盖 base 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},

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

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