VUE 集成 Electron 报错

前言

我用vue cli 4.0创建了一个简单的vue app,并成功地将其与electron集成。一切都运行得很好,直到我尝试在vue文件中导入electron。问题是我不能通过ipcRenderer向主进程发送消息。

Uncaught TypeError: fs.existsSync is not a function
    at getElectronPath (index.js?1704:7)
    at eval (index.js?1704:18)
    at Object../node_modules/_electron@11.0.0@electron/index.js (chunk-vendors.js:10)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/AppTitle/TitleBtn.vue?vue&type=script&lang=js&:2)
    at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/AppTitle/TitleBtn.vue?vue&type=script&lang=js& (app.js:1031)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)

解决方法

在 vue.config.js 中添加

nodeIntegration: true

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值