关于Electron remote为undefined的问题

在学习的ELectron时碰到的问题,没有其他方面的问题,仅仅是remote无法饮用的情况下:

解决方案

由于Electron最新版本将enableRemoteModule默认值设置为false,所以要在新建BrowserWindow的时候将其打开才能使用:

  win =  new BrowserWindow({
    
    
    width:800 ,
    height:600 ,
    minWidth:800,
    minHeight:600,
    maxWidth:1000,
    maxHeight:800,
    webPreferences:{
    
    
      nodeIntegration:true,
      enableRemoteModule:true
    },
  })
官方:enableRemoteModule Boolean (optional) - Whether to enable the remote module. 默认值为 false.

Guess you like

Origin blog.csdn.net/weixin_41564885/article/details/108560033