electron中要获取到屏幕尺寸,需要引入screen模块
例子如下:
const remote = require('electron').remote;
const screen = remote.screen;
const {width,height} = screen.getPrimaryDisplay().workAreaSize;//获取到屏幕的宽度和高度
console.log(width,height);
const screen = remote.screen;
const {width,height} = screen.getPrimaryDisplay().workAreaSize;//获取到屏幕的宽度和高度
console.log(width,height);