vue|nwjs监听右上角关闭事件close,提示是否关闭

效果如下:
【vue|nwjs监听右上角关闭事件close,提示是否关闭】vue|nwjs监听右上角关闭事件close,提示是否关闭
文章图片

代码如下:
这里用到了vue + element-ui的弹出框,
如果自己写一个弹出框也行的,

mounted(){ // 监听软件右上角关闭点击 nw.Window.get().on('close',async function(){console.log('this-win',this)// 如果点击确定就关闭 let rel = await that.answerFun('确定关闭?') console.log('结果:',rel) if(rel){// 调用关闭函数 this.close(true) } }) }, methods:{answerFun(tipText) {return new Promise((resolve, reject) => {this.$confirm( tipText, '提示', {type: 'warning' }) .then(async () => {resolve(true); }) .catch(() => {resolve(false); }); }); }, }

不懂可以评论咨询!

    推荐阅读