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);
});
});
},
}
不懂可以评论咨询!
推荐阅读
- vue-cli|vue-cli 3.x vue.config.js 配置
- 2020-04-07vue中Axios的封装和API接口的管理
- VueX--VUE核心插件
- Quartz|Quartz 源码解析(四) —— QuartzScheduler和Listener事件监听
- vue组件中为何data必须是一个函数()
- 用npm发布一个包的教程并编写一个vue的插件发布
- vuex|vuex 基础结构
- Vue源码分析—响应式原理(二)
- VueX(Vuex|VueX(Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式)
- vue中的条件判断详解v-if|vue中的条件判断详解v-if v-else v-else-if v-show