菜单点击时不加载页面
问题描述:
我试图创建一个菜单,在启动时用主窗口打开各种页面。这是一个被设置为在包开始运行我的js文件:菜单点击时不加载页面
var win = null;
function getAppMenu()
{
var menu = new nw.Menu({type: 'menubar'});
menu.append(new nw.MenuItem({
label: 'Home',
click: function(){
win.open('index.html');
alert('asdf');
}
}));
menu.append(new nw.MenuItem({
label: 'Inventory',
click: function(){
alert('asdf');
win.open('inventory.html', {}, function(win){});
}
}));
return menu;
}
nw.Window.open('index.html', {id:'main', fullscreen:false, resizable: true, width:800, height:600, focus:true}, function(newwin){
win = newwin;
newwin.menu = getAppMenu();
});
的菜单设置,但是当我单击菜单项,页面没有加载。我究竟做错了什么?
答
win
是一个nwjs对象的实例,它不包含open
(使用nw.Window.open
代替打开一个新窗口)。如果你想在别处导航,win.window.location.href = "URL";
是你正在寻找。
祈祷告诉为什么这是downvoted,并接近投票。我现在已经生气了,他们的机器人攻击了我。它发生在我现在发布的最后2个问题上。 – user3791372