亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

電子應用程序不會啟動,準備就緒時不存在

電子應用程序不會啟動,準備就緒時不存在

慕碼人8056858 2022-06-16 15:26:16
我已經做了幾天了,我已經從 Electron GitHub 克隆了電子快速啟動(https://github.com/electron/electron-quick-start)我收到了這個錯誤,但它不是t 只為這個應用程序,它是所有的應用程序。我不知道發生了什么。電子最新版本:8.2.0 錯誤app.whenReady().then(createWindow)     ^TypeError: Cannot read property 'whenReady' of undefined    at Object.<anonymous> (/Users/user/Downloads/electron-quick-start-master/main.js:25:5)    at Module._compile (internal/modules/cjs/loader.js:1147:30)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)    at Module.load (internal/modules/cjs/loader.js:996:32)    at Function.Module._load (internal/modules/cjs/loader.js:896:14)    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)    at internal/main/run_main_module.js:17:47代碼:const electron = require('electron')// Modules to control application life and create native browser windowconst {app, BrowserWindow} = require('electron')const path = require('path')function createWindow () {  // Create the browser window.  const mainWindow = new BrowserWindow({    width: 800,    height: 600,    webPreferences: {      preload: path.join(__dirname, 'preload.js')    }  })  // and load the index.html of the app.  mainWindow.loadFile('index.html')  // Open the DevTools.  // mainWindow.webContents.openDevTools()}// This method will be called when Electron has finished// initialization and is ready to create browser windows.// Some APIs can only be used after this event occurs.app.whenReady().then(createWindow)// Quit when all windows are closed.app.on('window-all-closed', function () {  // On macOS it is common for applications and their menu bar  // to stay active until the user quits explicitly with Cmd + Q  if (process.platform !== 'darwin') app.quit()})app.on('activate', function () {  // On macOS it's common to re-create a window in the app when the  // dock icon is clicked and there are no other windows open.  if (BrowserWindow.getAllWindows().length === 0) createWindow()})
查看完整描述

3 回答

?
慕尼黑5688855

TA貢獻1848條經驗 獲得超2個贊

本身不是一個答案——我只是在Electron我目前正在進行的一個項目中嘗試了這個,它運行良好:


app.whenReady().then((choice) => {

    console.log("hey, I'm ready", choice);   

})

對于現實檢查,我建議使用 ready 事件:


app.on('ready', function () {

  console.log("hey, I'm ready too!");   

});

Electron盡管我突然想問:您使用的是什么版本?如果您使用的是 7 或 8 之前的版本,他們還沒有開始“承諾”的東西(我忘記了開始使用的版本Promises)


查看完整回答
反對 回復 2022-06-16
?
米脂

TA貢獻1836條經驗 獲得超3個贊

您的電子版本低于 v3.0.0。

我們可以whenReady()從 3.0.0 版本開始使用。建議您更新您的電子版。


查看完整回答
反對 回復 2022-06-16
?
繁星淼淼

TA貢獻1775條經驗 獲得超11個贊

謝謝大家幫助我,但我已經解決了這個問題:我所要做的就是在前兩行之后加上分號,


const {app, BrowserWindow} = require('electron');

const path = require('path');

而不是這個


const {app, BrowserWindow} = require('electron')

const path = require('path')


查看完整回答
反對 回復 2022-06-16
  • 3 回答
  • 0 關注
  • 173 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號