原项目使用nw.js 0.12开发。
升级至nw.js 0.18.8
IDE webstorm
gui.Window.open 无法打开窗口
取消 toolbar设置
路径由xx.html改为/xxx/xx.html (老版本自动定位到xx目录,新版本定位为项目根目录)
DevToolsAPI is not defined
https://dl.nwjs.io/v0.18.8/nwjs-sdk-v0.18.8-win-x64.zip
使用0.xx.x sdk进行构建
nw.gui.Window.open 无返回值 ( Cannot read property ‘on’ of undefined)
0.12版是这样定义的
var myWin=nw.gui.Window.open("url",{});
0.13版是改成了
callback(win) {Function} Optional callback when with the opened native Window object
//nw.gui.Window.open("url",{},{callback});
nw.gui.Window.open("url",{},function(win){
myWin=win;
});
关于global的使用变化配合angular1.x
启动main.html
{
show.false,
….
…
}
main.html
<html>
<head>
<script src="a.js" >
</head>
<body>
<button ng-click="openB()">点我调用nw.gui.Window.open()b页</button>
</body>
</html>
a.js
global.executeA=function(){ ...}
b.html
<html>
<head>
<script src="c.js" >
<script src="f.js" >
</head>
<body>
<button ng-click="executeA()">我来执行A</button>
//(0.12)下面是修改前的使用方法
<button ng-click="gS.executeA()">我来执行A</button>
</body>
</html>
c.js
(function(window) {
function executeA(){
global.executeA();
}
window.executeA=executeA;
})(this);
//(0.12)修改前没有这个c.js
f.js
//这里为什么用angular而不是直接在页面调用c.js,因为这样事件不仅交给了angular管理更可以舒服的使用ng-if,ng-click,ng-ini,ng-repeat
angular.module('xxx')
.run(function($rootScope) {
$rootScope.executeA= executeA;
...
...
})
//(0.12)下面是修改前的方法。使用factory把global转为gS提供给html页面使用
angular.module('xxx')
.factory('gS', function() {
return global;
})