简体   繁体   中英

Electron + Angular Application + Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment:

I have the angular + electron app with the below structure

在此处输入图像描述

Routes in the Angular App looks like this, with the lazy load for the wrapper modules

 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}, ];

The code works perfectly well when launched as a Angular application in browser localhost:4200. However, it doesn't work if it launched as Electron app. The HomeComponent, which is the default route comes up perfectly fine in Electron BrowserWindow. However the following URLs doesn't work with lib URL

Without hash

Not allowed to load local resource: file:///D:/Technical/ElectronJS/Demo2/electron-demo/dist/electron-demo/index.html/lib

With hash

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'index.html' core.js:4061 file:///D:\Technical\ElectronJS\Demo2\electron-demo\dist\electron-demo\index.html#\lib

What am I doing wrong here?

Got the solution. If someone is looking for the answer, the solution mentioned in this post solved the problem: https://stackoverflow.com/a/62010347/4951812

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM