2
我努力让自己在点击应用窗口全屏,但得到以下错误main.js:29 Uncaught TypeError: Cannot read property 'setFullScreen' of undefined
电子集全屏的onclick
main.js
const electron = require('electron')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 1200, height: 600})
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`)
// Open the DevTools.
mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
}
function toggleFullScreen() {
mainWindow.setFullScreen(true)
}
我要上点击全屏默认情况下不 – ingsaurabh
感谢它的工作,你可以点我一些教程学习电子,因为大多数的例子我在网络上找到使用电子旧的版本,所以也没有什么帮助 – ingsaurabh
哦对不起,当我开始时,我遇到了同样的问题,只是检查文档并询问我在这里学到了如何处理一些问题。 –