我无法让 <router-outlet></router-outlet>
在我的 Angular 电子应用程序中呈现任何内容。如果我运行 ng serve 那么我可以看到路由器在工作,但在我运行时却看不到 electron .
这是一个空白的应用程序。
我的 index.html 文件有 <base href="./">
,我的 main.js 文件在下面。我该怎么做才能使电子的角度布线很好地发挥作用?感谢您的帮助!
main.js
const { app, BrowserWindow } = require('electron')
const url = require("url");
const path = require("path");
let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/index.html`),
protocol: "file:",
slashes: true
})
);
// Open the DevTools.
// mainWindow.webContents.openDevTools()
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
app.on('activate', function () {
if (mainWindow === null) createWindow()
})
答案 0 :(得分:0)
您确定 Angular 应用程序甚至被加载到浏览器中吗? Electron docs 提到您需要在窗口准备好后显示它:
mainWindow.once('ready-to-show', () => {
mainWindow.show();
}
其他一些调试技巧: