美文网首页
Nuxt之Electron开发

Nuxt之Electron开发

作者: HomWang | 来源:发表于2019-06-20 17:45 被阅读0次

地址:https://www.homwang.com 欢迎大家性能测试
交流讨论——QQ群号:604203227
nuxt.js+Electron开始一个demo
准备工作:

  1. 需要具备vue.js基础
  2. 需要了解一些最长用的nuxt.js的配置
  3. 有需求或学习

测试系统:
mac
nuxt.js测试版本号:

  • 2.8.1
    必要条件:
  • node 8.9.3+
  • npm 5.0+ (or yarn)
  • vue-cli 2.1+ (vue -V)

安装:

  1. vue init nuxt-community/electron-template my-project
  2. cd my-project
  3. npm install # Or yarn

开发:
npm run dev

打包:
npm run build

注意事项:

  1. 使用less,而非使用sass,因为node-sass目前暂未正式发布声明说支持Electron,而且我已经测试过node-sass不行,在版本正确的情况下依旧不行
  2. 需要修改根目录代码
    win = new electron.BrowserWindow({ icon: path.join(__dirname, 'static/icon.png'), webPreferences: { nodeIntegration: true } })
  3. nuxt.config.js要设置为mode: 'spa'
  4. 注意体积的相关优化
  5. 如果打包出现 报错 node_modules/app-builder-bin/mac/app-builder exited with code 1 关键字
  • 需要清空 ~/Library/Caches/electron/
  1. 图片资源文件一定是需要放在assets目录下,static只能放icon图标,否则图片资源会直接找不到。

目前发现的问题就这些,解决这些问题项目就ok了。

相关文章

网友评论

      本文标题:Nuxt之Electron开发

      本文链接:https://www.haomeiwen.com/subject/klijqctx.html