如图要实现分享给好友,操作如下:
必须要依赖于button按钮的open-type属性:
html:
<button open-type='share' class="share-btn" plain="true">
分享
</button>
js:
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
var page = this;
return {
title: this.data.name,//分享的标题
desc: '',//描述
path: "/pages/goods/goods?id=" + this.data.id,//跳转的路径链接
}
},
做好后效果图: