nodeWebKit 0.12版本迁移0.18 迁移记录

原项目使用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;
        })
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值