小程序页面实现转发的操作流程分享

Admin 2021-05-27 群英行业资讯

我们先来看看官方文档上的内容:

官方文档上说通过给 button 组件设置属性 open-type="share",可以在用户点击按钮后触发 Page.onShareAppMessage 事件,相关组件:button。

官网文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html

第一种情况 点击小程序转发

不加入参数

  //转发
  onShareAppMessage: function() {
    let users = wx.getStorageSync('user');
    if (res.from === 'button') {}
    return {
      title: '转发',
      path: '/pages/index/index',
      success: function(res) {}
    }
  }

加入参数

  //转发
  onShareAppMessage: function() {
    let users = wx.getStorageSync('user');
   if (res.from === 'button') {}
    return {
      title: '转发',
      path: '/pages/index/index?from_uid=' + users.id,
      success: function(res) {}
    }
  }

第二种:分享

这个分享必须做成button 且加上 open-type="share"

不加入参数

  onShareAppMessage: function (res) {
    if (res.from === 'button') {
    }
    return {
      title: '转发',
      path: '/pages/index/community/topic/topic',
      success: function (res) {
        console.log('成功', res)
      }
    }
  }

加入参数

  //转发
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
 
    }
    return {
      title: '转发',
      path: '/pages/index/community/topic/topic?jsonStr=' + this.data.list,
      success: function (res) {
        console.log('成功', res)
      }
    }
  }

提醒:这里转发的参数要在onLoad 的options 运用

相关推荐:小程序开发教程

以上就是如何在小程序页面内进行转发操作的详细内容,更多请关注群英网络其它相关文章!

(来源:csdn

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。

猜你喜欢

云活动 云活动
群英网络助力开启安全的云计算之旅
立即注册,领取新人大礼包
  • 联系我们
  • 24小时售后:4006784567
  • 24小时TEL :0668-2555666
  • 售前咨询TEL:400-678-4567

  • 官方微信

    官方微信
Copyright  ©  QY  Network  Company  Ltd. All  Rights  Reserved. 2003-2019  群英网络  版权所有   茂名市群英网络有限公司
增值电信经营许可证 : B1.B2-20140078   粤ICP备09006778号
免费拨打  400-678-4567
免费拨打  400-678-4567 免费拨打 400-678-4567 或 0668-2555555
微信公众号
返回顶部
返回顶部 返回顶部