问题
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