WeChat Mini Program - Share the page to the circle of friends function (two steps)

foreword

Official document: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html

For the applet that has not set the function of sharing the circle of friends, the button of sharing circle of friends is gray and cannot be clicked, as shown in the following figure:
insert image description here

If the Mini Program page has the Share Moments function enabled, it is available, as shown in the following figure:

1. Turn on the function

On the page where you want to enable the function of sharing circle of friends, call wx.showShareMenu()Open , and the button of sharing circle of friends will be activated (from gray to available), as shown in the figure above.

Open the *.jsfile onLoadand add the following code to the life cycle:

// index.js

Guess you like

Origin blog.csdn.net/weixin_44198965/article/details/123132616