2017-02-09 138 views
0

我有一个NW应用程序,它以启动画面开始,然后在新窗口中打开主应用程序。该代码是大约这样的:gui.Window.open()返回undefined

var appWin = gui.Window.open("https://localhost:8080/", { 
    "icon": "app_icon.png", 
    "frame": true, 
    "width": 1200, 
    "height": 800, 
    "position": "center", 
    "resizable": true, 
    "min_width": 400, 
    "min_height": 200 
}) 

appWin.on('loaded', function() { 
    // hide the splash screen 
}) 

然而,appWin总是undefined,即使新窗口打开并显示正确的内容。

我使用的是nw-builder版本0.13.4,但我也尝试过0.14.x,0.15.x和0.16.x的各种版本,但也有同样的问题。

任何可行的解决方法的建议也是可以接受的。

回答

1
// Open a new window. 
nw.Window.open("https://localhost:8080/", { 
    "icon": "app_icon.png", 
    "frame": true, 
    "width": 1200, 
    "height": 800, 
    "position": "center", 
    "resizable": true, 
    "min_width": 400, 
    "min_height": 200 
}, function(win) { 
     console.log('window opened'. win); 
     win.on('loaded', function() { 
      console.log('window created'); 
     } 
}); 
+0

谢谢。我没有在任何文档中看到这种用法。 –

+0

http://docs.nwjs.io/en/latest/References/Window/#windowopenurl-options-callback – VoidVolker