NW.js —— 在浏览器端调用 Node.js 模块

    xiaoxiao2023-07-10  156

    NW.js 详细介绍NW.js 可以让你直接在 DOM 上调用所有 Node.js 模块,相当于使用一种新的方法来编写 Web 应用。NW.js 的前身是 node-webkit 。

    特性:

    使用 HTML5、CSS3、JS 和 WebGL 编写应用完全支持 Node.js APIs 以及其 第三方模块性能表现良好,Node 和 WebKit 运行在同一个线程,函数调用更直接,对象在同一个内存堆中,可直接引用方便打包和分发支持跨平台

    演示程序:https://github.com/zcbenz/nw-sample-apps

    示例:

    index.html <!DOCTYPE html> <html> <head> <title>Hello World!</title> </head> <body> <h1>Hello World!</h1> We are using node.js <script>document.write(process.version)</script>. </body> </html> package.json: { "name": "nw-demo", "main": "index.html" }

    运行:

    $ /path/to/nw . (suppose the current directory contains 'package.json')

    文章转载自 开源中国社区 [http://www.oschina.net]

    最新回复(0)