|
|
Posted on 2025-2-20 08:52:38
|
|
|
|

Requirements: When using WebView nested in the WeChat mini program, when you need to click to share with friends or circle of friends, the user clicks on the shared card to enter the display H5 page.
First, let's take a look at the renderings shared into the chat:
Principle: The H5 page sends a message to the mini program, and the mini program clicks to share to read the message, as shown in the figure below:
bindmessage eventhandler No When a web page sends a postMessage to the mini program, it will trigger and receive a message at the following specific times: the mini program is backtracked, the component is destroyed, shared, and the link is copied (2.31.1). e.detail = { data }, data is an array of parameters that have been posted multiple times.
wx.miniProgram.postMessage sends a message to the mini program, which triggers the component's message event at the following specific times: mini program back, component destruction, sharing, copy link (2.31.1)
web-view:The hyperlink login is visible.
H5 page
The H5 page uses postMessage to send a message to the applet, and the code is as follows:
WeChat mini program
The code is as follows:
Note: What is shared is still the mini program page path, but the parameter link of the h5 page must be attached to the path.
onShareAppMessage: Used when sharing with friends or group chats. onShareTimeline: Used to configure when sharing to Moments.
Procedure:
The operation steps are as follows:
|
Previous:.NET/C# uses HttpClient common request trick methodsNext:RMSE, MSE, MAE, SD brief introduction
|