【问题标题】:Menu doesn't load page when clicked单击时菜单不加载页面
【发布时间】:2017-10-15 21:52:30
【问题描述】:

我正在尝试创建一个菜单,以便在启动时使用主窗口打开各种页面。这是我设置为在包启动时运行的 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();
    });

菜单已设置,但是当我单击任一菜单项时,页面未加载。我做错了什么?

【问题讨论】:

  • 请告诉为什么这被否决了,并且投票结束了。现在他们的机器人攻击了我,我生气了谁。它发生在我现在发布的最后两个问题上。

标签: nw.js


【解决方案1】:

win 是一个不包含open 的nwjs 对象的实例(使用nw.Window.open 代替打开一个新窗口)。如果您想在其他地方导航,win.window.location.href = "URL"; 就是您要找的。​​p>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-09
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    • 2011-04-10
    相关资源
    最近更新 更多