簡體   English   中英

從BrowserWindow電子類擴展時出錯

[英]Error when extending from BrowserWindow electron class

我使用https://github.com/SimulatedGREG/electron-vue模板創建了vue電子模板。 在主流程index.js旁邊,我創建了一個文件MainWindow.js ,其中包含以下代碼:

import { BrowserWindow } from 'electron';

export class MainWindow extends BrowserWindow {
  constructor(url) {
    super({
      height: 500,
      width: 300,
      frame: false,
      resizable: false,
      show: false,
      webPreference: { backgroundThrottling: false }
    });
    console.log('constructor called.');

    // this.loadURL(url);
    this.on('blur', this.onBlur.bind(this));
  }

  onBlur() {
    this.hide();
  }
}

現在,當我嘗試創建MainWindow的實例時,出現以下錯誤:

Requires constructor call

function createWindow() {
  /**
   * Initial window options
   */
  mainWindow = new MainWindow();

  mainWindow.loadURL(winURL);

  mainWindow.on('closed', () => {
    mainWindow = null;
  });
}

我不知道為什么會發生此錯誤,因為我正確使用了new

您不應該從BrowserWindow繼承。 當前不支持。

查看:

https://github.com/electron/electron/issues/23

https://github.com/electron/electron/issues/8898

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM