【发布时间】: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
我在这里做错了什么?
【问题讨论】: