// app.js
const Store = window.electron.require('electron-store')
const fileStore = new Store()
// preload.js
const { contextBridge } = require('electron')
contextBridge.exposeInMainWorld('electron', {
fs: require('fs'),
require: window.require,
})
在渲染进程中new store就报错,electron版本是30.0,electron-store: 6.0.1。新版本中无法在渲染进程中直接使用window.require来引入模块了,所以只好把require模块暴露出来
报错如下
Uncaught Error: Class constructor ElectronStore cannot be invoked without 'new'