electron 创建右键菜单
Posted Lonely existence, lonely burni
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了electron 创建右键菜单相关的知识,希望对你有一定的参考价值。
1、引入模块 const Electron = require(‘electron‘); const remote = Electron.remote; const Menu = remote.Menu; const MenuItem = remote.MenuItem; 2、 data() { return { isShowMember:false, menu:null, } }, created() { this.targetId = this.id; notificationCenter.on("onClosePop", this.onClosePop); this.initMenu(); }, 3、methods: { //初始化右键菜单 initMenu(){ this.menu = new Menu(); let that = this; this.menu.append(new MenuItem({ label: ‘删除‘, click: function() { //删除本地文件. that.imServices.deleteLocationMsgFiles(that.rightMessage); //删除消息 that.imServices.removeMessages(that.rightMessage.peer, that.rightMessage.msgID); that.rightMenuMsg(that.rightMessage); } })); }, rightShow(item) { this.rightMessage = item; this.menu.popup(remote.getCurrentWindow()); },
以上是关于electron 创建右键菜单的主要内容,如果未能解决你的问题,请参考以下文章