当我尝试使用我的window.history.back()
文件的直接网址(例如http://localhost:4200/index.html)访问我的Angular 2应用程序时,所有内容都会按预期运行。
但是,我在我的应用程序中使用Angular Router并希望实现一个后退按钮。
遵循Angular文档只需调用index.html
函数就可以完成我想要的工作。当我在最后没有http://localhost:4200/index.html
访问我的应用程序时(例如http://localhost:4200/),这是真的。
但是,当我使用此browser_adapter.ts:84 EXCEPTION: Error: Uncaught (in promise): Error: Cannot match any routes: 'index.html/about'
browser_adapter.ts:74 EXCEPTION: Error: Uncaught (in promise): Error: Cannot match any routes: 'index.html/about'BrowserDomAdapter.logError @ browser_adapter.ts:74BrowserDomAdapter.logGroup @ browser_adapter.ts:85ExceptionHandler.call @ exception_handler.ts:50(anonymous function) @ application_ref.ts:353schedulerFn @ async.ts:140SafeSubscriber.__tryOrUnsub @ Subscriber.ts:240SafeSubscriber.next @ Subscriber.ts:192Subscriber._next @ Subscriber.ts:133Subscriber.next @ Subscriber.ts:93Subject._finalNext @ Subject.ts:154Subject._next @ Subject.ts:144Subject.next @ Subject.ts:90EventEmitter.emit @ async.ts:125onError @ ng_zone.ts:134onHandleError @ ng_zone_impl.ts:87ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233_loop_1 @ zone.js:487drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
browser_adapter.ts:74 STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.ts:74ExceptionHandler.call @ exception_handler.ts:53(anonymous function) @ application_ref.ts:353schedulerFn @ async.ts:140SafeSubscriber.__tryOrUnsub @ Subscriber.ts:240SafeSubscriber.next @ Subscriber.ts:192Subscriber._next @ Subscriber.ts:133Subscriber.next @ Subscriber.ts:93Subject._finalNext @ Subject.ts:154Subject._next @ Subject.ts:144Subject.next @ Subject.ts:90EventEmitter.emit @ async.ts:125onError @ ng_zone.ts:134onHandleError @ ng_zone_impl.ts:87ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233_loop_1 @ zone.js:487drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
browser_adapter.ts:74 Error: Uncaught (in promise): Error: Cannot match any routes: 'index.html/about'
at resolvePromise (zone.js:538)
at zone.js:515
at ZoneDelegate.invoke (zone.js:323)
at Object.onInvoke (ng_zone_impl.ts:64)
at ZoneDelegate.invoke (zone.js:322)
at Zone.run (zone.js:216)
at zone.js:571
at ZoneDelegate.invokeTask (zone.js:356)
at Object.onInvokeTask (ng_zone_impl.ts:53)
at ZoneDelegate.invokeTask (zone.js:355)BrowserDomAdapter.logError @ browser_adapter.ts:74ExceptionHandler.call @ exception_handler.ts:54(anonymous function) @ application_ref.ts:353schedulerFn @ async.ts:140SafeSubscriber.__tryOrUnsub @ Subscriber.ts:240SafeSubscriber.next @ Subscriber.ts:192Subscriber._next @ Subscriber.ts:133Subscriber.next @ Subscriber.ts:93Subject._finalNext @ Subject.ts:154Subject._next @ Subject.ts:144Subject.next @ Subject.ts:90EventEmitter.emit @ async.ts:125onError @ ng_zone.ts:134onHandleError @ ng_zone_impl.ts:87ZoneDelegate.handleError @ zone.js:327Zone.runGuarded @ zone.js:233_loop_1 @ zone.js:487drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
zone.js:461 Unhandled Promise rejection: Cannot match any routes: 'index.html/about' ; Zone: angular ; Task: Promise.then ; Value: Error: Cannot match any routes: 'index.html/about'(…)consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
zone.js:463 Error: Uncaught (in promise): Error: Cannot match any routes: 'index.html/about'(…)
之类的链接访问应用程序然后尝试使用我的后退按钮时,我收到以下错误:
index.html
因为我将Angular 2与Electron结合使用,我需要使用以{{1}}
结尾的URL访问该页面如何解决此问题?
答案 0 :(得分:0)
网址与任何路线都不匹配。
如果您已按照Angular团队提供的文档进行操作,则可能已将基本href设置如下:
<base href="/">
请尝试将其设置为:
<script>document.write('<base href="' + document.location + '" />');</script>