Electron使用remote报错
简介Uncaught TypeError: Cannot destructure property 'Menu' of 'remote' as it is undefined.
为了实现在渲染进程中创建右键菜单,但是如果直接使用remote,运行程序会报如下错误:Uncaught TypeError: Cannot destructure property 'Menu' of 'remote' as it is undefined.
从v9版本开始,remote除非将设置enableRemoteModule为true,否则不允许在渲染器上使用。所以在主进程main.js中,需要设置该属性:
//其他代码...
app.on('ready', () => {
require('./menu.js')
mainWindow = new BrowserWindow({
width: 800,
height: 400,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule:true,//添加即可解决问题
}
})
//其他代码...
})
如果只是修改了上面,我们继续使用
const { Notification } = require('electron').remote
会提示(electron) The remote module is deprecated,因为remote将被废弃,替代它的是需要参考:@electron/remote
@electron/remote的使用
#1、先安装
npm install --save @electron/remote
#2、在主进程中进行初始化
require('@electron/remote/main').initialize()
#3、渲染进程中使用
// in the renderer process:
// Before
const { BrowserWindow } = require('electron').remote
// After
const { BrowserWindow } = require('@electron/remote')
在使用Git的过程中,不想每次都输入用户名和密码去拉取代码,所以就需要保存这些信息,那么既然有保存了,就必须有清除功能。
Python调用WPS把文档转换PDF,并把PDF转图片,首先需要安装WPS,然后利用pypiwin32把文档转化成PDF,再利用fitz、PyMuPD把PDF转化成图片
chkconfig命令是Redhat系列的Linux系统中的系统服务管理工具,他们可以用于查询和更新不同的运行等级下系统服务的启动状态
直方图(Histogram)又称质量分布图,是一种统计报告图,由一系列高度不等的纵向条纹或线段表示数据分布的情况,一般用横轴表示数据类型,纵轴表示分布情况,本文主要介绍关于Python matplotlib.pyplot.hist()绘制直方图
用supervisord管理python进程,python程序中的print内容不能输出到指定的日志文件
快速生成表格
Electron页面跳转、浏览器打开链接和打开新窗口
在Mac电脑中,如何对Git的用户名和密码进行修改呢?起初不懂Mac,所以整了很久,本文将记录如何对这个进行操作,以便后期使用。
Docker编译镜像出现:fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory问题