小程序单个页面分享+自定义分享按钮

在这里插入图片描述

<view class="share-box">
  <image data-id="{{article.id}}" bindtap="videoShare" class='video-share' src='/images/icon/class/share2.png'/>
  <button data-id="{{article.id}}" class='video-share-btn' plain="{{true}}" open-type="share"> </button>
</view>
// 分享
 onShareAppMessage: function (id) {
   return {
     title: '孕育课堂',
     path: '/pages/pregnantClass/detail/index?id='+id,    //分享的页面所需要的id
     imageUrl: this.data.article.video_img   //分享界面的图片
   }
 },

注意

样式:

1.onShareAppMessage方法,必须使用<button open-type="share">, open-type="share"放在别的组件上无效

2.<button> 有个属性 plain 设置为true,然后用定位将自己的图片和button重合在一起即可

分享:

1.onShareAppMessage 方法中 path 后面的 id,是你需要分享的页面所需要的id,传过去即

可,onLoad(options)可以接收到,如果不需要id,就传个空或者随便123都行

2.onShareAppMessage 方法中的 imageUrl 就是分享界面的图片
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值