一些前期准备是需要的:node,npm,单页面 本人使用cnpm,单页面应用
参考:
https://github.com/jiahaog/nativefier
https://github.com/jiahaog/nativefier/blob/master/docs/api.md#dest
https://github.com/jiahaog/nativefier/issues/45
安装:
npm i -g nativefier
//-g代表安装到全局
nativefier 文档:https://github.com/jiahaog/nativefier/blob/master/docs/api.md
打包,默认当前路径:
nativefier --name "Sample" "index.html"
或者
nativefier --name "Sample" --insecure --ignore-certificate index.html
其实也可以直接修改配置文件
找到 \app\nativefier.json 文件,将targetURL更改为“targetUrl”:“file:///index.html”或 “http://www.baidu.com”
注:修改为file:///index.html方式时,需要把静态资源(index.html)等存放在.exe 同一路径,如下图: