vue+electron问题汇总

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()
})

…待续

相关推荐

  1. pandas常见问题汇总

    2023-12-08 10:46:03       63 阅读
  2. 【前端】常见问题汇总

    2023-12-08 10:46:03       35 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-08 10:46:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-08 10:46:03       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-08 10:46:03       82 阅读
  4. Python语言-面向对象

    2023-12-08 10:46:03       91 阅读

热门阅读

  1. Redisson配置

    2023-12-08 10:46:03       59 阅读
  2. 【IC前端虚拟项目】工程目录组织说明

    2023-12-08 10:46:03       61 阅读
  3. 第四十二篇,MATLAB on Linux

    2023-12-08 10:46:03       67 阅读
  4. 上机实验四 哈希表设计 西安石油大学数据结构

    2023-12-08 10:46:03       45 阅读
  5. TS学习——快速入门

    2023-12-08 10:46:03       53 阅读
  6. ssl什么是公钥和私钥?

    2023-12-08 10:46:03       67 阅读
  7. Gateway:微服务架构中的关键组件

    2023-12-08 10:46:03       58 阅读
  8. 什么是https加密协议

    2023-12-08 10:46:03       67 阅读
  9. 代码随想录-刷题第二十天

    2023-12-08 10:46:03       68 阅读