【发布时间】:2018-06-01 03:04:15
【问题描述】:
我正在添加 contextIsolation,因为我正在我的 web 视图中加载远程内容。
在预加载脚本中使用webFrame.executeJavascript(...),如何将不可序列化的对象传递给内部网页的上下文?
更具体地说,这是我的例子:
preload.js:
// In the preload.js context
const { ipcRenderer, webFrame } = require('electron')
const ipc = {
send (data) {
ipcRenderer.sendToHost(...)
}
}
// Now I want to pass down ipc to the webpage's context
// This webpage is expecting window.myApp.ipc, so that it could use it like window.myApp.ipc.send(...)
webFrame.executeJavaScript(`window.myApp.ipc = ${ipc}`); // Doesn't work.
【问题讨论】:
标签: electron