【问题标题】:npm run electron is working but not displaying any thingnpm run electron 工作但不显示任何东西
【发布时间】:2019-03-08 17:40:25
【问题描述】:

我正在关注此代码https://coursetro.com/posts/code/125/Angular-5-Electron-Tutorial,但它正在运行但没有显示任何内容。什么问题?

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()
    }
})

【问题讨论】:

    标签: angular electron electron-builder


    【解决方案1】:

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

    win.webContents.openDevTools();
    

    这将打开开发者窗口,您将能够检查您的错误。

    【讨论】:

    • 无法识别
    猜你喜欢
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-29
    • 2020-11-05
    • 1970-01-01
    相关资源
    最近更新 更多