Sharing and forwarding in WeChat Mini Programs is mainly divided into two situations
- Click on the upper right menu to share
- Button click to share
These two types of clicks will trigger the execution of the Page.onShareAppMessage() function when clicked
The process of realizing the button button forwarding effect
Set the attribute open-type="share" on the button component and automatically trigger the execution of the onShareAppMessage() function when clicked
The internal structure of onShareAppMessage must have return {} onShareAppMessage official introduction
The onShareAppMessage function in the js file
<button type="primary" open-type="share" >转发</button>
onShareAppMessage: function (res) {
console.log(res)
return{
title:'转发小程序时顶部的 标题文字',
path:'/pages/zhuan/zhuan',
imageUrl:"https://inews.gtimg.com/newsapp_bt/0/13258080263/1000"
}
}