We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 1、创建一对 port const { port1, port2 } = new MessageChannel() console.log('ceshi', port1) // 2、给主进程传输消息端口 port1 window.electron.ipcRenderer.postMessage( 'port', { msg: '我是渲染进程一通过 ipcRenderer.postMessage 发送过来的' }, [port1] ) // 3、把 port2 赋值给 portToMain,方便其他模块获取 let portToMain = port2 // 4、port2 绑定事件监听,之后主进程发送的消息都会在这里接收到 portToMain.onmessage = (event) => { const data = event.data console.log('[portToMain]message', data) }
报错 Error: Invalid value for transfer 看官网的写法就是这样写的 https://www.electronjs.org/zh/docs/latest/api/ipc-renderer#ipcrendererpostmessagechannel-message-transfer
最新
The text was updated successfully, but these errors were encountered:
没用正确使用,主进程需要使用ipcMain来处理,这里和electron-vite无关。
https://www.electronjs.org/zh/docs/latest/api/message-port-main
Sorry, something went wrong.
没用正确使用,主进程需要使用ipcMain来处理,这里和electron-vite无关。 https://www.electronjs.org/zh/docs/latest/api/message-port-main
这里只贴了渲染进程的代码,主进程没贴。 在preload/index.js文件里面写是正常的,在vue页面里面写就会报错。
No branches or pull requests
Describe the bug
报错 Error: Invalid value for transfer
看官网的写法就是这样写的
https://www.electronjs.org/zh/docs/latest/api/ipc-renderer#ipcrendererpostmessagechannel-message-transfer
Electron-Vite Version
最新
Electron Version
最新
Vite Version
最新
Validations
The text was updated successfully, but these errors were encountered: