electron-vue报错:(index):1 Uncaught ReferenceError: require is not defined at (index):1

报错:

(index):1 Uncaught ReferenceError: require is not defined
    at (index):1
(index):1 Uncaught ReferenceError: process is not defined
    at (index):1
renderer.js:1 Uncaught ReferenceError: module is not defined
    at renderer.js:1

 解决方法:

在窗口的webPreferences中加入以下配置

nodeIntegration: true,

contextIsolation:false

完整代码:

  mainWindow = new BrowserWindow({
    height: 563,
    useContentSize: true,
    width: 1000,
    webPreferences:{
      webSecurity:false,
      nodeIntegration: true,
      contextIsolation:false
    }
  })

你可能感兴趣的:(electron,electron,vue.js,javascript)