How should I configure the base href for Angular 2 when using Electron?

断了今生、忘了曾经 提交于 2019-12-21 06:58:05

问题


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:

EXCEPTION: Error: Uncaught (in promise): Cannot match any routes. Current segment: 'C:'. Available routes: ['/dashboard', '/accounts'].

I tried using just the HashLocationStrategy mentioned in this blog post, but Angular still complains about the base href not being set.


回答1:


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="./">


来源:https://stackoverflow.com/questions/37265855/how-should-i-configure-the-base-href-for-angular-2-when-using-electron

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!