地址:https://www.homwang.com 欢迎大家性能测试
交流讨论——QQ群号:604203227
nuxt.js+Electron开始一个demo
准备工作:
- 需要具备vue.js基础
- 需要了解一些最长用的nuxt.js的配置
- 有需求或学习
测试系统:
mac
nuxt.js测试版本号:
- 2.8.1
必要条件: - node 8.9.3+
- npm 5.0+ (or yarn)
- vue-cli 2.1+ (vue -V)
安装:
- vue init nuxt-community/electron-template my-project
- cd my-project
- npm install # Or yarn
开发:
npm run dev
打包:
npm run build
注意事项:
- 使用less,而非使用sass,因为node-sass目前暂未正式发布声明说支持Electron,而且我已经测试过node-sass不行,在版本正确的情况下依旧不行
- 需要修改根目录代码
win = new electron.BrowserWindow({ icon: path.join(__dirname, 'static/icon.png'), webPreferences: { nodeIntegration: true } })
- nuxt.config.js要设置为
mode: 'spa'
- 注意体积的相关优化
- 如果打包出现 报错 node_modules/app-builder-bin/mac/app-builder exited with code 1 关键字
- 需要清空 ~/Library/Caches/electron/
- 图片资源文件一定是需要放在assets目录下,static只能放icon图标,否则图片资源会直接找不到。
目前发现的问题就这些,解决这些问题项目就ok了。
网友评论