WeChat Mini Program API-Repost (Share)

Sharing and forwarding in WeChat Mini Programs is mainly divided into two situations

  1. Click on the upper right menu to share
  2. 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"
    }
  }

 

Forward official documents

 

Guess you like

Origin blog.csdn.net/weixin_41040445/article/details/114580969