【问题标题】:__dirname is not defined importing electron remote__dirname 未定义导入电子遥控器
【发布时间】:2020-09-30 22:45:09
【问题描述】:

我有问题。我想在无框窗口上设置最小化、最大化和关闭按钮,但由于导入电子遥控器的问题,我不能。谢谢。

import { remote } from "electron";

 methods...

 closeWindow() {
  var window = remote.getCurrentWindow();
  window.close();
}

【问题讨论】:

  • 您需要在创建 browserWIndow 时启用 nodeIntegration
  • 好,现在我得到“fs.existsSync 不是函数”:/
  • npm install fs --save
  • 安装 fs 不能解决这个问题@tpikachu

标签: vue.js webpack electron electron-vue


【解决方案1】:

就这样导入:

const { remote } = window.require('electron')

然后你的代码:

methods...    
closeWindow() {
  remote.getCurrentWindow().close();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-09
    • 2021-08-03
    • 2021-03-05
    • 2020-12-16
    • 1970-01-01
    • 2021-07-01
    • 1970-01-01
    • 2020-07-11
    相关资源
    最近更新 更多