首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >render.js中不可见的电子性质

render.js中不可见的电子性质
EN

Stack Overflow用户
提问于 2020-12-17 16:05:01
回答 1查看 196关注 0票数 0

我正在努力学习如何构建电子应用程序,我在Youtube教程中找到了一个简单的屏幕记录应用程序,但是我遇到了这个错误。

未定义的TypeError:无法破坏“远程”的“菜单”属性,因为它没有定义。在render.js:9

下面是教程代码中的确切代码

代码语言:javascript
复制
const videoElement = document.querySelector('video');
const startBtn = document.getElementById('startBtn');
const stopBtn = document.getElementById('stopBtn');
const videoSelectBtn = document.getElementById('videoSelectBtn');
videoSelectBtn.onclick = getVideoSources;

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

const {Menu} = remote;

async function getVideoSources(){

const inputSources = await desktopCapturer.getSources({
    types:['window','screen']
});
const videoOptionsMenu = Menu.buildFromTemplate(
    inputSources.map(source =>{
   return{
       label:source.name,
       click:()=>selectSource(souce)
   }
    })
);
videoOptionsMenu.popup();
}

我做错什么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-17 16:16:31

电子的新版本。您需要允许您的电子应用程序使用远程模块。在主电子代码中添加enableRemoteModule: true标志。

代码语言:javascript
复制
mainWindow = new BrowserWindow({
    width: 1280,
    height: 960,
    webPreferences: {
      nodeIntegration: true,
      enableRemoteModule: true,
     },
  });
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65344217

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档