npm运行电子正在工作,但不显示任何东西

时间:2018-10-03 13:16:28

标签: angular electron electron-builder

我正在遵循此代码https://coursetro.com/posts/code/125/Angular-5-Electron-Tutorial,但是它正在运行,但是什么也没有显示。有什么问题吗?
enter image description here

const { app, BrowserWindow } = require('electron')
const path = require('path')
const url = require('url')

let win

function createWindow() {
    win = new BrowserWindow({ width: 800, height: 600 })
    win.webContents.openDevTools();
    // load the dist folder from Angular
    win.loadURL(url.format({
        pathname: path.join(__dirname, 'dist/index.html'),
        protocol: 'file:',
        slashes: true
    }))

    // Open the DevTools optionally:
    // win.webContents.openDevTools()

    win.on('closed', () => {
        win = null
    })
}

app.on('ready', createWindow)


app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit()
    }
})

app.on('activate', () => {
    if (win === null) {
        createWindow()
    }
})

1 个答案:

答案 0 :(得分:-1)

将以下代码粘贴到createWindow函数中

win.webContents.openDevTools();

这将打开开发人员窗口,您将可以检查错误。

相关问题