前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >WeChat小程序如何实现转发功能?

WeChat小程序如何实现转发功能?

作者头像
江咏之
发布2022-06-16 08:58:00
6120
发布2022-06-16 08:58:00
举报
文章被收录于专栏:技术社区

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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

一、点击小程序转发

在这里插入图片描述
在这里插入图片描述
1. 不加参数
代码语言:javascript
复制
 //转发
 onShareAppMessage: function() {
     let users = wx.getStorageSync('user');
     if (res.from === 'button') {}
     return {
        title: '转发',
        path: '/pages/index/index?from_uid=' + users.id,
        success: function(res) {}
     }
 } 
2.加入参数
代码语言:javascript
复制
 //转发
 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"

1.不加参数
代码语言:javascript
复制
 onShareAppMessage: function (res) {
 if (res.from === 'button') {
 }
 return {
  title: '转发',
  path: '/pages/index/community/topic/topic',
  success: function (res) {
  console.log('成功', res)
  }
 }
 }
2.加入参数
代码语言:javascript
复制
 //转发
 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)
  }
 }
 }
在这里插入图片描述
在这里插入图片描述

onShareAppMessage与生命周期同级

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-08-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、点击小程序转发
  • 二、点击按钮分享
相关产品与服务
云开发 CloudBase
云开发(Tencent CloudBase,TCB)是腾讯云提供的云原生一体化开发环境和工具平台,为200万+企业和开发者提供高可用、自动弹性扩缩的后端云服务,可用于云端一体化开发多种端应用(小程序、公众号、Web 应用等),避免了应用开发过程中繁琐的服务器搭建及运维,开发者可以专注于业务逻辑的实现,开发门槛更低,效率更高。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档