微信小程序 分享实现

 
 
<view class='carDesc carDesc1'> <text>金氏养猪场 </text> <button class='share' id="shareBtn" open-type="share" type="primary" hover-class="other-button-hover"> <image src='../../images/share.png'> </image> 分享 </button> </view>
上面是 WXML 代码
下面是 js代码
 
  
onShareAppMessage: function (ops) { if (ops.from === 'button') { // 来自页面内转发按钮 console.log(ops.target) } return { title: 'xx小程序', path: 'pages/index/index', success: function (res) { // 转发成功 console.log( "转发成功:" + JSON.stringify(res)); }, fail: function (res) { // 转发失败 console.log( "转发失败:" + JSON.stringify(res)); } } }
 
  

回调结果:

回调类型 errMsg 说明
success shareAppMessage:ok 转发成功
fail shareAppMessage:fail cancel 用户取消转发
fail shareAppMessage:fail (detail message) 转发失败,其中 detail message 为详细失败信息
 
  


猜你喜欢

转载自blog.csdn.net/qq_38363371/article/details/79154054