【问题标题】:Index.html not link to app.component in electron angularIndex.html 未链接到电子角度中的 app.component
【发布时间】: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


    【解决方案1】:

    关注this 存储库。它将帮助您在开发环境和生产环境中设置角度。

    【讨论】:

      猜你喜欢
      • 2022-01-17
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      • 2019-08-18
      • 1970-01-01
      • 2016-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多