Electron-Vue中使用require報錯


在electron-vue中嘗試使用ipcRenderer進行通信時,控制台報錯提示:_dirname is not defined

搜索相關資料后得到如下結論:

1.修改background.js文件

 

win = new BrowserWindow({
        width: 1200,
        height: 800,
        frame: false,
        resizable: false,
        transparent: true,
        webPreferences: {
            webSecurity: false,
+            nodeIntegration: true,
+            contextIsolation:false
            // nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
            //contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION
        }
    })

 

2. 修改require("electron") 為 window.require("electron")

 


免責聲明!

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



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