Jquery 接收从loadFile发送到electron中html页面的数据
我有Jquery 接收从loadFile发送到electron中html页面的数据,jquery,electron,Jquery,Electron,我有main.js页面,其中我使用mainWindow.loadFile('./app/main.html',options)加载名为main.html的新文件 同时,我还发送了以json结构存储数据的选项 如何在main.html页面中接收和使用此选项数据 使用loadFile加载main.html页面。我们如何检索发送的数据?在HTML页面中,您必须解析窗口的URL 如果从主进程发送这些选项 mainWindow.loadFile(“./app/main.html”){ 查询:{queryK
main.js
页面,其中我使用mainWindow.loadFile('./app/main.html',options)
加载名为main.html的新文件
同时,我还发送了以json结构存储数据的选项
如何在main.html页面中接收和使用此选项
数据
使用loadFile加载main.html页面。我们如何检索发送的数据?在HTML页面中,您必须解析窗口的URL 如果从主进程发送这些选项
mainWindow.loadFile(“./app/main.html”){
查询:{queryKey:“queryValue”},
hash:“hashValue”,
});
在HTML页面中(渲染器进程)
console.log(location.href)//YOUR_PATH/app/main.html?queryKey=queryValue#hashValue
console.log(location.search)/?queryKey=queryValue
console.log(location.hash)/#hashValue
//您可能需要使用URLSearchParams
const params=新的URLSearchParams(location.search)
console.log(params.get(“queryKey”)//queryValue