1.创建vue项目
vue create electron-demo
//or
vue ui

2.在vue项目中安装Vue CLI Plugin Electron Builder
修改electron镜像再安装vue add electron-builder
查看配置文件的位置
npm config list

找到打开该文件 添加
registry=https://registry.npm.taobao.org
electron_mirror="https://npm.taobao.org/mirrors/electron/"
安装后Vue CLI Plugin Electron Builder的package.json文件

vue add electron-builder
//若安装失败直接淘宝镜像安装
vue add electron-builder --registry=https://registry.npm.taobao.org
3.运行
yarn electron:serve
//or
npm run electron:serve

注:首次启动可能会等待很久,出现以下信息:

这是因为在请求安装vuejs devtools插件,Devtools的安装需要翻墙。所以我们目前不需要安装他
注释掉src/background.js中的以下代码再次运行就可以了
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
try {
await installExtension(VUEJS_DEVTOOLS)
} catch (e) {
console.error('Vue Devtools failed to install:', e.toString())
}
}
网友评论