electron-vue的安装与运行

electron-vue:这个一个基于 vue 使用 electron 的模板(项目)。
该项目的目的,是为了要避免使用 vue 手动建立起 electron 应用程序。electron-vue 充分利用 vue-cli 作为脚手架工具,加上拥有 vue-loader 的 webpack、electron-packager 或是 electron-builder,以及一些最常用的插件,如vue-router、vuex 等等。

安装与运行

# 安装 vue-cli 和 脚手架样板代码
npm install -g vue-cli
vue init simulatedgreg/electron-vue my-project
# 安装依赖并运行你的程序
cd my-project
yarn # 或者 npm install
yarn run dev # 或者 npm run dev

运行结果如下:

报错总结

  1. 报错信息如下:
Command vue init requires a global addon to be installed.
Please run yarn global add @vue/cli-init and try again.

解决方法npm install -g @vue/cli-init

  1. 报错信息:ERROR in Template execution failed: ReferenceError: process is not defined ERROR in ReferenceError: process is not defined

解决方法:在 node v12 +中,需要显式导入流程模块。在index.ejs中修改:process.browser -> require('process').browser
参考:https://github.com/SimulatedGREG/electron-vue/issues/871#issuecomment-564302194

// 报错前
<% if (!process.browser) { %>
// 修改后不报错
<% if (!require('process').browser) { %>

原文地址:https://www.cnblogs.com/unlockth/p/13576655.html