- nw.js即可使用nw.js的api,还可以使用node的api
// 1.使用nw.js api
let menu = new nw.Menu();
menu.append(new nw.MenuItem({
label: '菜单一',
click: function () {
alert('clicl item1')
}
}))
// menu.append(new nw.MenuItem({label:'项1'}))
// menu.append(new nw.MenuItem({type: 'separator'})) // 分界线
// menu.append(new nw.MenuItem({label:'项2'}))
document.body.addEventListener('contextmenu',function(ev){
console.log(ev);
// 阻止默认菜单项
ev.preventDefault();
// 弹出自定义菜单
menu.popup(ev.x,ev.y);
return false;
},false)
// 2.使用node api
const os = require('os')
document.write('您当前系统为:',os.platform())