类型错误:无法读取未定义的属性“whenReady”

Rus*_*nov 4 javascript node.js electron

我对电子有疑问。

\n
\n

类型错误:无法读取未定义的属性“whenReady”

\n
\n

我使用\n节点 14.0.1\n电子 10.1.2

\n

我运行我的应用程序\n"electron:serve": "vue-cli-service electro:serve",

\n

我的背景.js

\n
const { app, BrowserWindow } = require('electron')\nconst { server } = require('feature-server-core')\n\nserver.start();\n\nfunction createWindow () {\n    // \xd0\xa1\xd0\xbe\xd0\xb7\xd0\xb4\xd0\xb0\xd0\xb5\xd0\xbc \xd0\xbe\xd0\xba\xd0\xbd\xd0\xbe \xd0\xb1\xd1\x80\xd0\xb0\xd1\x83\xd0\xb7\xd0\xb5\xd1\x80\xd0\xb0.\n\n    const win = new BrowserWindow({\n        width: 1400,\n        height: 900,\n        minWidth: 1280,\n        minHeight: 800,\n        closable: true,\n        center: true,\n        type: "tool",\n        titleBarStyle: "hidden",\n    })\n\n    win.menuBarVisible = false;\n// \xd0\xb8 \xd0\xb7\xd0\xb0\xd0\xb3\xd1\x80\xd1\x83\xd0\xb6\xd0\xb0\xd0\xb5\xd0\xbc index.html \xd0\xb2 \xd0\xbf\xd1\x80\xd0\xb8\xd0\xbb\xd0\xbe\xd0\xb6\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb8.\n    win.loadURL("google.com")\n}\n\napp.whenReady().then(() => {\n    createWindow()\n\n    app.on('activate', function () {\n        // On macOS it's common to re-create a window in the app when the\n        // dock icon is clicked and there are no other windows open.\n        if (BrowserWindow.getAllWindows().length === 0) createWindow()\n    })\n})\n\n// Quit when all windows are closed, except on macOS. There, it's common\n// for applications and their menu bar to stay active until the user quits\n// explicitly with Cmd + Q.\napp.on('window-all-closed', function () {\n    if (process.platform !== 'darwin') app.quit()\n})\n
Run Code Online (Sandbox Code Playgroud)\n

小智 5

'index.js'这是与直接调用with 节点(如 )相关的问题node index.js。您需要使用electron index.jselectron .(如果您的文件是index.js)电子正在构建您的应用程序。