【发布时间】:2019-06-18 07:46:10
【问题描述】:
我正在使用 Electron 开发一个应用程序。使用 win.loadFile('index.html') 曾经可以工作,但从昨天开始它会抛出一个错误:win.loadFile is not a function。
会不会是“Knex.js”导致了这个错误?因为我最近安装了它,然后问题开始出现。另外,我注意到 Electron 图标从透明变为浅蓝色(绿色)圆圈。
此外,使用loadURL 可以工作,但它会不完整地呈现 html 文件。
这是我的 main.js(我从 main.js 中删除了 knex.js 代码但没有帮助):
const { app, BrowserWindow } = require('electron')
const url = require('url')
const path = require('path')
function createWindow () {
// Create the browser window.
let win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
// and load the index.html of the app.
win.loadFile('index.html');
}
app.on('ready', createWindow)
【问题讨论】: