【发布时间】:2021-04-22 07:41:46
【问题描述】:
我无法让<router-outlet></router-outlet> 在我的角度电子应用程序中渲染任何内容。如果我运行 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()
})
【问题讨论】: