【问题标题】:Electron loadFile is not a functionElectron loadFile 不是函数
【发布时间】: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)

【问题讨论】:

    标签: electron knex.js


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-10-25
      • 2021-03-17
      • 2017-08-23
      • 2018-09-03
      • 2020-06-12
      • 1970-01-01
      • 1970-01-01
      • 2019-12-27
      • 2019-01-06
      相关资源
      最近更新 更多