1. Vue_Bug Failed to fetch extension, trying 4 more times
描述:项目启动时报错
解决:注释图片中内容
2. Module not found: Error: Can’t resolve ‘fs’ in
描述:项目启动报错
解决:vue.config.js中添加图中数据
3.导入electron.remote后,remote为undefined
解决: 开启remote模块
enableRemoteModule: true
4.electron 点击事件无效
解决:
给点击的按钮加
-webkit-app-region: no-drag; 就可以点击了
5. electron设置frame:false后close关闭方法失效
解决:
关闭按钮所在vue页面
<i class="el-icon-close" @click="handelClose"></i>
// 方法
// 引入
import {
remote, ipcRenderer } from 'electron';
// 使用
handelClose() {
this.$confirm('确定退出?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
ipcRenderer.send('window-close')
}).catch(() => {
});
},
background.js文件添加
ipcMain.on('window-close',function (){
win = null // 主窗口设置为null防止内存溢出, win设置为全局变量,默认是常量
app.exit()
})
…待续