【问题标题】:Electron + Angular Application + Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment:Electron + Angular Application + 错误:未捕获(承诺):错误:无法匹配任何路由。网址段:
【发布时间】:2020-09-21 18:44:14
【问题描述】:

我有具有以下结构的 angular + electron 应用程序

Angular 应用程序中的路由看起来像这样,包装模块的延迟加载

const routes: Routes = [
  {path: 'lib', loadChildren: () => import('./wrapper/wrapper.module').then(m => m.WrapperModule)},
  {path: 'home', loadChildren: () => import('./wrapper/homewrapper.module').then(m => m.HomewrapperModule)},
  {path: '', component: HomeComponent},
];

当在浏览器 localhost:4200 中作为 Angular 应用程序启动时,该代码运行良好。但是,如果它作为 Electron 应用程序启动,它就不起作用。作为默认路由的 HomeComponent 在 Electron BrowserWindow 中非常好。但是以下 URL 不适用于 lib URL

无哈希

不允许加载本地资源:file:///D:/Technical/ElectronJS/Demo2/electron-demo/dist/electron-demo/index.html/lib

带哈希

ERROR 错误:未捕获(在承诺中):错误:无法匹配任何路由。 URL 段:'index.html' core.js:4061 file:///D:\Technical\ElectronJS\Demo2\electron-demo\dist\electron-demo\index.html#\lib

我在这里做错了什么?

【问题讨论】:

    标签: angular electron


    【解决方案1】:

    找到解决方案。如果有人在寻找答案,这篇文章中提到的解决方案解决了这个问题:https://stackoverflow.com/a/62010347/4951812

    【讨论】:

      猜你喜欢
      • 2019-02-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 2018-08-22
      • 2022-11-10
      • 2023-02-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多