node-webkit 環境搭建與基礎demo

來源:互聯網
上載者:User

標籤:

首先去github上面下載(地址),具體更具自己的系統,我的是windows,這裡只給出windows的做法

下載windows x64版本

 

下載之後解壓,得到以下東西

 

 

為了方便,我們直接在這個目錄中建立我們的項目

添加app檔案夾,並添加index.html

<html>

<head>

    <title>windowdemo</title>

    <metahttp-equiv="Content-Type"content="text/html; charset=utf-8"/>

</head>

<body>

    <h1>window api 測試</h1>

    <script>

    var gui = require(‘nw.gui‘);

    var win = gui.Window.get();

    win.on(‘minimize‘, function () {

        var element = document.createElement(‘div‘);

        element.appendChild(document.createTextNode(‘視窗最小化‘));

        document.body.appendChild(element);

    });

    new_win.on(‘focus‘, function () {

        var element = document.createElement(‘div‘);

        element.appendChild(document.createTextNode(‘新視窗被啟用‘));

        document.body.appendChild(element);

        win.removeAllListeners(‘minimize‘);

    });

    </script> 

</body>

</html>

 

然後在app檔案夾給你們一路下添加package.json

 

{

  "name": "window-demo",

  "main": "index.html",

  "nodejs":true,

  "width":100,

  "height":200,

   "window": {

    "title": "windowdemo",

    "toolbar": true, 

    "width": 800, 

    "height": 600,

   "resizable":true,

   "show_in_taskbar":true,

   "frame":true,

   "kiosk":false

  },

  "webkit":{

  "plugin":true

  }

}

其中,name和main是必須配置的,其他的參考官方地址,就是下載頁

配置好之後,我們就可以運行我們的應用程式了!運行方式有兩種,一種是到app目錄下直接將所有檔案壓縮為app.zip;然後將app.zip拖到nw.exe中運行

第二種就是進入cmd模式

 

好了,到此就是所有基礎的東西;這裡貼出完整的所有東西的百度雲下載,避免有些朋友不能FQ

連結: http://pan.baidu.com/s/1kU8Eind 密碼: wamb

node-webkit 環境搭建與基礎demo

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.