1.首先在wxml中输入
<web-view src='{{url}}' bindtap='toShare'></web-view>
2.js中在
onShareAppMessage 周期函数中触发绑定的toShare事件
onShareAppMessage(option) {
this.toShare();
...//在此处获取option中取到的title和img等属性值
return {
title: title,
imageUrl: imageUrl,
path: 'pages/...,//小程序的跳转路径
success: function (res) {
console.log(res)
// 转发成功
},
fail: function (res) {
console.log(res)
// 转发失败
}
}
}