微信小程序 API-转发(Share)

微信小程序中 分享转发,主要分为两种情况

  1. 右上角 menu 点击分享
  2. 按钮点击分享

这两种点击,在点击的时候都会触发 Page.onShareAppMessage() 函数的执行

实现button按钮转发效果的流程

在button组件上设置属性 open-type=“share” 点击的时候回自动触发 onShareAppMessage() 函数执行

onShareAppMessage 内部结构  必须有return {}    onShareAppMessage 官方介绍

js文件中 的onShareAppMessage函数

  <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"
    }
  }

 

转发 官方文档

猜你喜欢

转载自blog.csdn.net/weixin_41040445/article/details/114580969