我正在尝试将 Electron 添加到现有的 Angular 项目中。
我添加的就像新的应用程序一样,我认为我的配置正确,但是当我运行 Electron 应用程序时,屏幕上没有任何显示。
这是main.js,我如何加载 Electron 应用程序的index.html。
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('./src/index.html')
win.setMenu(null);
}
index.html =><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Testing</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="icon" type="image/x-icon" href="favicon.ico"> -->
</head>
<body>
<app-root></app-root>
</body>
</html>
app.component.html<h1 class="app-root">Welcome to sub-app1!</h1>
<router-outlet></router-outlet>
这是app-router.component.tsconst routes: Routes = [
{
path: '',
redirectTo: 'test',
pathMatch: 'full'
},
{
path: 'test',
component: TestComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
我在app.component.ts的构造函数中添加了一个控制台,但没有显示任何内容。当我运行此 Electron 子应用程序时,屏幕上没有任何显示。看起来像index和app.component.ts,而不是链接。
我想念的是什么?
最佳答案
遵循this存储库。它会帮助您与开发环境和生产环境建立一定的 Angular 。
关于angular - Index.html不在 Electron Angular 中链接到app.component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65978016/