electron与react直接通讯

https://www.electronjs.org/zh/docs/latest/api/ipc-renderer

 

main.js

mainWindow.webContents.on('did-finish-load', () => {
    console.log(128888888,process.argv)
    mainWindow.webContents.send("from-main", process.argv);
 });

 

react

import { ipcRenderer } from 'electron';
 useEffect(() => {
        ipcRenderer.on('from-main',(event,params)=>{
            console.log(359,params[2])
            setLocationurl(params[2]);
        })
    }, []);

 

https://www.likecs.com/ask-3211063.html

posted @ 2023-01-10 15:25  小小强学习网  阅读(130)  评论(0编辑  收藏  举报