本文首发于个人博客 Cyy’s Blog
转载请注明出处 https://cyyjs.top/blog/5d6cda89d7933a1f338b105f

# 1、electron报错fs.existsSync is not a function

vue.config.js增加如下配置:

module.exports = {
  // options...
  configureWebpack: config => {
    config.target = 'electron-renderer'
  }
}

创建窗口时增加如下参数:

mainWindow = new BrowserWindow({
  width: 1200,
  height: 780,
  titleBarStyle: 'hidden',
  webPreferences: {
    webSecurity: false,
    nodeIntegration: true // 启用node集成
  }
})