electron Uncaught TypeError: Cannot read property 'dialog' of undefined


 

electron Uncaught TypeError: Cannot read property 'dialog' of undefined

 

const remote = window.require('electron').remote;
const dialog =remote.dialog;//此行報錯

 

網上說是electron為了安全默認是關閉的,所以要打開:

解決方法:

mainWindow = new BrowserWindow({
    width:600,
    height:800,
    /* 啟用Node繼承 */
    webPreferences:{
      nodeIntegration:true,
      enableRemoteModule:true
    }
  })

在background.js 中可能如下引用

import { dialog } from 'electron'

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM