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;
        })
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章