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) { %>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM