小程序分享
小程序中除了右上角的自带分享之外,还可以做成点击按钮分享
wxml
<button class="bottom_in" open-type="share" id="share" plain="true" >
<image class="img" src="../../img/my/share.png"></image>
</button>
其中open-type="share"是核心属性,且只能由button元素触发
js
//分享
onShareAppMessage: function (res) {
if (res.from === 'button') {
console.log(res.target)
}
return {
title: this.data.info.name+',
path: '/pages/detail/detail?id='+this.data.book_id+'&share=1',
success: function (res) {
console.log('成功', res)
}
}
},
小程序会默认截取当且页面作为分享的背景图,也可自行设置