nw 使用手记,用js 写桌面程序
安装 node.js , 将npm 添加至系统变量,下载 Git ,Git的bin目录路径添加至系统变量,如C:\Program Files\Git\bin
新建一目录,nw, 目录下再建一目录 source
nw目录 建一文件 package.json(文件名)
{
"scripts": {
"dev": "nw /source/",
"prod": "nwbuild --platforms win32,win64 --buildDir dist1/ source/"
},
"devDependencies": {
"nw-builder": "^3.5.4"
}
}
然后再在 source 目录下 建一文件 package.json(文件名)
{
"name": "helloworld",
"main": "index.html",
"version": "0.1.0",
"description": "A simple SkyRTC demo",
"devDependencies": {
"grunt-nw-builder": "^3.1.0",
"nw-builder": "^3.5.1"
}
}
同样在source 目录下 建一文件 index.html (文件名) 注:这个页面像网页一样是可以调用各种js的。。
<!DOCTYPE html>
<html>
<head>
<title>我的第一个js桌面程序</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
然后再
npm install nw-builder --save-dev
安装完成后再回到 nw 目录 执行
npm run prod
运行效果如下
