第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

mainWindow 未定義 electron js

mainWindow 未定義 electron js

紅顏莎娜 2022-12-02 15:51:26
我在ElectronJS中制作了一個(gè)應(yīng)用程序,并嘗試在事件中加載不同的 html 文檔。但是當(dāng)我嘗試這樣做時(shí),出現(xiàn)了這個(gè)錯(cuò)誤(見(jiàn)下圖)那么,我做錯(cuò)了什么,還是有不同的方法..?這是我的代碼:const { app, BrowserWindow, ipcMain } = require('electron')const path = require('path');function createWindow () {  // Create the browser window.  const mainWindow = new BrowserWindow({    width: 800,    height: 600,    icon: "icon.png",    webPreferences: {      nodeIntegration: true    }  })  mainWindow.loadFile("index.html");}app.whenReady().then(() => {    createWindow()    app.on('activate', function () {        if(BrowserWindow.getAllWindows.length === 0) createWindow()    })}).catch(err => console.log(err))app.on('window-all-closed', function () {    if(process.platform !== 'darwin') app.quit()})ipcMain.on("login", (event, data) => {    Authenticator.getAuth(data.u, data.p).then(() => {        event.sender.send('done')              mainWindow.loadURL(path.join(__dirname, "home.html"))    }).catch((err) => {        event.sender.send("err", { er: err })    })})
查看完整描述

1 回答

?
人到中年有點(diǎn)甜

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊

您在其中定義了它c(diǎn)reateWindow;在該功能之外無(wú)法訪問(wèn)它。


所以返回它,然后在調(diào)用時(shí)捕獲它c(diǎn)reateWindow:


function createWindow () {

  // ...

  return mainWindow;

}


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

    const mainWindow = createWindow()



查看完整回答
反對(duì) 回復(fù) 2022-12-02
  • 1 回答
  • 0 關(guān)注
  • 83 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)