如何解决electron中使用remote模块时出现的undefined错误问题?
- 内容介绍
- 文章标签
- 相关推荐
本文共计335个文字,预计阅读时间需要2分钟。
之前的项⽬中,我们使用了Electron的remote模块来直接调用,但近期使用Electron时频繁出现错误。我在遇到问题后迅速查阅了官方文档,发现并未提及Electron进行了更新。
之前的项目,引用electron的remote可以直接调用 electron.remote 来去使用,而近期使用electron却频繁报错???踩坑后我快速去查看了下官方文档,是不是electron进行了更新?果然不出所料,在electron 10中,修改了enableRemoteModule默认为false,我们需要手动将其修改为true。
此前版本中我们使用electron中的remote模块时,不需在主进程的窗口中加入 enableRemoteModule:true 参数才能够调用remote模块,而在 electron 10 中,我们需要加入该参数才能调用该模块。
//引入electron let electron = require('electron') //引入remote模块 let remote = electron.remote //打印remote模块 console.log(remote)
在未加入参数前,会引起报错。
本文共计335个文字,预计阅读时间需要2分钟。
之前的项⽬中,我们使用了Electron的remote模块来直接调用,但近期使用Electron时频繁出现错误。我在遇到问题后迅速查阅了官方文档,发现并未提及Electron进行了更新。
之前的项目,引用electron的remote可以直接调用 electron.remote 来去使用,而近期使用electron却频繁报错???踩坑后我快速去查看了下官方文档,是不是electron进行了更新?果然不出所料,在electron 10中,修改了enableRemoteModule默认为false,我们需要手动将其修改为true。
此前版本中我们使用electron中的remote模块时,不需在主进程的窗口中加入 enableRemoteModule:true 参数才能够调用remote模块,而在 electron 10 中,我们需要加入该参数才能调用该模块。
//引入electron let electron = require('electron') //引入remote模块 let remote = electron.remote //打印remote模块 console.log(remote)
在未加入参数前,会引起报错。

