小程序同一页面不同按钮转发不同样式

wxml页面

<button class="share-btn" open-type="share" id="1"></button>
<button class="share-btn" open-type="share" id="2"></button>


js页面代码

onShareAppMessage: function (res) {
var that = this;
if (res.from == "button") {
if (res.target.id == 1) {
   return {
   title: '1要分享的标题',
    path: '/pages/index/index',
    success: function (res) {

  }
  }

}
   if (res.target.id == 2) {
return {
   title: '2要分享的标题',
    path: '/pages/index/index',
    success: function (res) {

  }
  }
}

}

//默认
else {
return {
   title: '右上角要分享的标题',
    path: '/pages/index/index',
    success: function (res) {

  }
  }

}
}

猜你喜欢

转载自www.cnblogs.com/studyh5/p/10108836.html