0


onShareAppMessage 微信小程序

onShareAppMessage(Object object)

监听用户点击页面内转发按钮(button 组件 open-type=“share”)或右上角菜单“转发”按钮的行为,并自定义转发内容。
注意:只有定义了此事件处理函数,右上角菜单才会显示“转发”按钮
在这里插入图片描述
在这里插入图片描述

Page({onShareAppMessage(){const promise =newPromise(resolve=>{setTimeout(()=>{resolve({title:'自定义转发标题'})},2000)})return{title:'自定义转发标题',path:'/page/user?id=123',
      promise 
    }}})
onShareAppMessage(res){var that =this
            console.log(that.goods_data)if(res.from==='button'){//分享按钮return{title:that.goods_data.share_title||that.goods_data.goods_name,// path: '',imageUrl:that.goods_data.share_img||that.goods_data.main_img,success:function(res){if(res.errMsg =='shareAppMessage:ok'){
                        console.log("成功",res)}},fail:function(res){
                      
                      console.log("失败",res)}}}else{return{title:that.goods_data.share_title||that.goods_data.goods_name,// path: '',imageUrl:that.goods_data.share_img||that.goods_data.main_img,success:function(res){if(res.errMsg =='shareAppMessage:ok'){
                        console.log("成功",res)}},fail:function(res){
                      
                      console.log("失败",res)}}}}

本文转载自: https://blog.csdn.net/qq_46199553/article/details/128851375
版权归原作者 程序猿向前跑 所有, 如有侵权,请联系我们删除。

“onShareAppMessage 微信小程序”的评论:

还没有评论