使用 Electron 时,我应该如何配置 Angular 2 的基本 href? [英] How should I configure the base href for Angular 2 when using Electron?
问题描述
我需要在 HTML 中设置 <base>
或在 Angular 2 引导期间设置 APP_BASE_HREF
以不引发异常.如果我设置了其中任何一个,则 Electron
,考虑到文件系统,在尝试匹配路由时会在 browser_adapter.ts
中引发异常:
I need to either set <base>
in the HTML or APP_BASE_HREF
during the bootstrap for Angular 2 to not throw exceptions. If I set either of these then Electron
, thinking in terms of the file system, throws exceptions in browser_adapter.ts
when trying to match a route:
异常:错误:未捕获(承诺中):无法匹配任何路由.当前段:'C:'.可用路由:['/dashboard', '/accounts'].
EXCEPTION: Error: Uncaught (in promise): Cannot match any routes. Current segment: 'C:'. Available routes: ['/dashboard', '/accounts'].
我尝试只使用 这篇博文,但 Angular 仍然抱怨未设置基本 href.
I tried using just the HashLocationStrategy
mentioned in this blog post, but Angular still complains about the base href not being set.
推荐答案
由于 href
属性可以采用相对路径,感谢@DavidC和@ChristianRondeau在问题的评论中进行验证,它应该像这样工作:
Since the href
attribute can take a relative path and thanks to @DavidC and @ChristianRondeau in the comments on the question for verifying, it should work like this:
<base href="./">
这篇关于使用 Electron 时,我应该如何配置 Angular 2 的基本 href?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!