首页 > 解决方案 > How to make window size responsive in Electron. (On the opening of the app)

问题描述

I recently started making an app on Electron, I wanted to make the window responsive, for example, if I open app on different screens it should open in full-size according to the screen size.
my code:

  app.on('ready', () => {
      const htmlPath = path.join('src', 'html/login.html')
      mainWindow1 = new BrowserWindow({ width: 1000 , height: 1000})
      mainWindow1.loadFile(htmlPath)

    })

Please help me with this.

标签: javascriptelectron

解决方案


创建你的后BrowserWindow,你应该打电话maximize()

mainWindow1 = new BrowserWindow();
mainWindow1.loadFile(htmlPath);
mainWindow1.maximize();

https://electronjs.org/docs/api/browser-window#winmaximize


推荐阅读