Electron结合React,在渲染进程中使用 node 模块
问题
将create-react-app与electron集成在了一个项目中。但是在React中无法使用electron。当在React中使用require('electron')时就会报TypeError: fs.existsSync is not a function的错误。因为React中无法使用Node.js的模块.
解决方法1
利用window.require引入
1 | const electron = window.require('electron') |


LiYongci
衔蝉
哈希米