WeChat Mini Program API Sharing
onShareAppMessage
Define the onShareAppMessage function in Page to set the sharing information of the page.
- Only when this event handler is defined, the "Share" button will be displayed in the upper right corner menu
- It will be called when the user clicks the share button
- This event requires Return an Object for custom sharing content
Custom sharing fields
Sample code:
Page({ onShareAppMessage: function () { return { title: '自定义分享标题', desc: '自定义分享描述', path: '/page/user?id=123' } } })
Bug & Tip
tip
: Shared pictures cannot be customized; the current page will be taken, starting from the top , an image with a height of 80% of the screen width as the share image.