uniapp分享功能加传递参数

 

与methods同级,可以直接调取小程序右上角的分享

onShareAppMessage(res) {

  if (res.from === 'button') {// 来自页面内分享按钮
    console.log(res.target)
  }
  return {
    title: '分享的标题',
    path: '分享的路径'
  }

}


点击button按钮实现分享,同样需要onShareAppMessage

<button open-type="share" :data-type='{title}' :data-id='{shareid}'></button>

注:如果需要带参数,data-后面加你声明的,例:data-id,在onShareAppMessage里面的res.target里面能找到传递的参数

 

 

原文地址:https://www.cnblogs.com/zjxiang008/p/13233798.html