gpt4 book ai didi

javascript - 类型错误 : Cannot read property 'getPrimaryDisplay' of undefined (screen. getPrimaryDisplay())

转载 作者:行者123 更新时间:2023-11-28 17:01:27 27 4
gpt4 key购买 nike

我正在尝试使用它来获取屏幕尺寸。在之前的版本上运行良好。无法在 Electron 6.0.0 上工作

const {remote} = require('electron');
const {desktopCapturer, screen} = require('electron');

var mainScreen = screen.getPrimaryDisplay();
var dimensions = mainScreen.size;

最佳答案

如果您想从渲染进程访问主进程模块,例如 screen,则必须使用 remote 模块。

const {remote, desktopCapturer} = require('electron'); // Renderer process modules
const {screen} = remote; // Main process modules

关于javascript - 类型错误 : Cannot read property 'getPrimaryDisplay' of undefined (screen. getPrimaryDisplay()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57327107/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com