电子loadFile不是函数

时间:2019-06-18 07:46:10

标签: electron knex.js

我正在使用Electron开发一个应用程序。使用win.loadFile('index.html')可以正常工作,但是从昨天开始,它会抛出一个错误:win.loadFile is not a function

可能是导致该错误的“ Knex.js”吗?因为我最近安装了它,之后问题开始出现。另外,我注意到电子图标从透明变为浅蓝色(绿色)圆圈。

此外,使用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)

1 个答案:

答案 0 :(得分:0)

检查您的Electron版本。您要运行的Electron版本,请全局安装。这是GitHub上的问题: BrowserWindow .loadFile is not a function

相关问题