In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
It is believed that many inexperienced people are at a loss about how webview in Electron communicates with the main process rendering process for event monitoring. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Webview calls the load page method to send via .executeJavaScript (code [, userGesture, callback]) or webview.send (), while listening with ipcRenderer.on () on the guest page
Attention, attention, attention:
If the guest page needs to call the method of the page where the webview resides, you need to add the attribute nodeintegration= "true" to the webview
The guest page (the resource page loaded by webview) is the page specified by src in webview (browser page)
If (window.require ('electron')) {let ipcRenderer = window.require (' electron'). IpcRenderer; ipcRenderer & & ipcRenderer.on ('webmsg', (e, msg) = > {console.log (message received by msg,'');}); ipcRenderer & & ipcRenderer.sendToHost ('I have received the message');}
Page where webview is located (client page)
Let webview = document.getElementById ('test')
Webview.addEventListener ('ipc-message', (event) = > {/ / ipc-message listening, information from the page loaded by webview
Console.log (event.channel) / / finally receive the message output sub-page information
})
If the setting does not take effect, please confirm here whether the property of nodeintegration= "true" is set on the webview tag.
After reading the above, have you mastered the method of event listening communication between webview and the main process rendering process in Electron? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.