我正在努力学习如何构建电子应用程序,我在Youtube教程中找到了一个简单的屏幕记录应用程序,但是我遇到了这个错误。
未定义的TypeError:无法破坏“远程”的“菜单”属性,因为它没有定义。在render.js:9
下面是教程代码中的确切代码
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();
}我做错什么了?
发布于 2020-12-17 16:16:31
电子的新版本。您需要允许您的电子应用程序使用远程模块。在主电子代码中添加enableRemoteModule: true标志。
mainWindow = new BrowserWindow({
width: 1280,
height: 960,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
},
});https://stackoverflow.com/questions/65344217
复制相似问题