请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

electron通过webview引入react搭建的h5页面, 并且相互通信

老师,我项目中需要在electron里面引入h5页面(react搭建),并且可以相互通信。

我用的electron的webview, 但是在react项目中通过 const {ipcRenderer} = require(‘electron’)来引入electron不行图片描述
请问这个怎么处理呢

正在回答

3回答

张轩 2020-07-14 09:37:34

同学你好 请问你新建窗口的是否使用了 nodeIntegration 选项?这个设置了才可以在前端页面中使用 node 模块。

let win = new BrowserWindow({  
    webPreferences: {    
        nodeIntegration: true
    }
})


1 回复 有任何疑惑可以回复我~
  • 提问者 姓廖名方正清 #1
    我知道了,需要在webview里面加入nodeIntegration这个参数
    回复 有任何疑惑可以回复我~ 2020-07-14 10:00:54
  • 提问者 姓廖名方正清 #2
    非常感谢!
    回复 有任何疑惑可以回复我~ 2020-07-14 17:32:25
qq_随心所欲_10 2020-10-23 15:23:30

Uncaught TypeError: fs.existsSync is not a function

    at getElectronPath (index.js:7)

    at Object.<anonymous> (index.js:18)

    at Object../node_modules/electron/index.js (index.js:18)

    at __webpack_require__ (bootstrap:832)

    at fn (bootstrap:129)

    at Module../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=js& (main.js:3752)

    at __webpack_require__ (bootstra


0 回复 有任何疑惑可以回复我~
qq_随心所欲_10 2020-10-23 15:23:01

Uncaught TypeError: fs.existsSync is not a function

    at getElectronPath (index.js:7)

    at Object.<anonymous> (index.js:18)

    at Object../node_modules/electron/index.js (index.js:18)

    at __webpack_require__ (bootstrap:832)

    at fn (bootstrap:129)

    at Module../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=js& (main.js:3752)

    at __webpack_require__ (bootstra

怎么解决的  我也是 哎  给钱教学啊

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号