Electron 子窗口总是空的
我需要创建两个具有进一步的窗口间通信的窗口。但现在我一直在创建子窗口:窗口正在创建,但没有内容。在devTools中,我只看到Electron 子窗口总是空的,electron,Electron,我需要创建两个具有进一步的窗口间通信的窗口。但现在我一直在创建子窗口:窗口正在创建,但没有内容。在devTools中,我只看到body标记。我使用vue-electron模板 我正在main/index.js中创建两个窗口,下面是完整的代码: 'use strict' import {app, BrowserWindow, Menu} from 'electron' /** * Set `__static` path to static files in production * htt
body
标记。我使用vue-electron
模板
我正在main/index.js
中创建两个窗口,下面是完整的代码:
'use strict'
import {app, BrowserWindow, Menu} from 'electron'
/**
* Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}
let mainWindow
const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:9080`
: `file://${__dirname}/index.html`
let childWindow
const childWinURL = `file://${__dirname}/categoryResults.html`
async function createWindow () {
const screen = require('electron').screen
const display = screen.getPrimaryDisplay()
let area = display.workArea
mainWindow = new BrowserWindow({
useContentSize: false,
width: area.width,
height: area.height,
webPreferences: {
webSecurity: false,
nodeIntegration: true, // to access node feautures in "browser" code
nodeIntegrationInWorker: true,
// nodeIntegrationInSubFrames: true
}
})
mainWindow.maximize()
await mainWindow.loadURL(winURL)
mainWindow.on('closed', () => {
mainWindow = null
})
}
async function createChildWindow () {
const screen = require('electron').screen
const display = screen.getPrimaryDisplay()
let area = display.workArea
childWindow = new BrowserWindow({
parent: mainWindow,
skipTaskbar: false,
autoHideMenuBar: true,
useContentSize: false,
width: area.width,
height: area.height,
webPreferences: {
webSecurity: false,
nodeIntegration: true, // to access node feautures in "browser" code
nodeIntegrationInWorker: true
}
})
await childWindow.loadURL(childWinURL)
childWindow.on('closed', () => {
childWindow = null
})
}
Menu.setApplicationMenu(null)
app.on('ready', async () => {
await createWindow()
await createChildWindow()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
如您所见,创建主窗口和创建子窗口几乎是相同的。但mainWindow有它的内容,而childWindow没有。在devtoolshtml中,我看到空的
:
这两个文件位于同一目录中:
html文件本身不是空的:
柔道分类成绩
来自分类结果的Hello world
//从“Vue”导入Vue
//警报('脚本标记正在工作')