【发布时间】:2021-05-04 18:18:09
【问题描述】:
我正在尝试将电子添加到现有的 Angular 项目中。
我像新应用程序一样添加,我认为我配置正确,但是当我运行我的电子应用程序时,屏幕上什么都没有显示。
这是main.js,我如何加载电子应用的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.ts
const routes: Routes = [
{
path: '',
redirectTo: 'test',
pathMatch: 'full'
},
{
path: 'test',
component: TestComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
我在 app.component.ts 的构造函数中添加了一个控制台,但没有打印出来。
当我运行这个电子子应用程序时,屏幕上什么也没有显示。看起来像 index 和 app.component.ts,而不是链接。
我错过了什么?
【问题讨论】:
标签: angular electron angular10