Skip to content
New issue

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

send-data无法获取到数据? #96

Open
EmKs opened this issue Aug 11, 2022 · 2 comments
Open

send-data无法获取到数据? #96

EmKs opened this issue Aug 11, 2022 · 2 comments

Comments

@EmKs
Copy link

EmKs commented Aug 11, 2022

let data = { url: "/test/web", resizable: true, webview: true, sendData: item }; ipcRenderer.invoke("open-win", data)
启动一个新页面
然后新页面
import { ipcRenderer } from "electron";
ipcRenderer.on("send-data", (event, data) => {
console.log(event)
console.log(data)
})
没有任何反应

@umbrella22
Copy link
Owner

因为新的页面展示会慢过send,这个将会在下个版本解决

@dehim
Copy link

dehim commented Dec 22, 2024

我也刚好遇到这个问题,我是这样解决的:

在“ipc-main-handle.ts”里:

const bindWebContentSend = (
  currentWindow: BrowserWindow,
  arg: { sendData?: unknown },
): void => {
  webContentSend.SendDataTest(currentWindow.webContents, arg.sendData)
}

OpenWin:()=>{
……
   // 改为‘did-finish-load’事件触发
    childWin.webContents.once('did-finish-load', () =>
      bindWebContentSend(childWin, arg),
    ), 
 ……

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants