onShareAppMessage(Object object)
监听用户点击页面内转发按钮(button 组件 open-type=“share”)或右上角菜单“转发”按钮的行为,并自定义转发内容。
注意:只有定义了此事件处理函数,右上角菜单才会显示“转发”按钮
文章来源地址https://www.toymoban.com/news/detail-508223.html
Page({
onShareAppMessage() {
const promise = new Promise(resolve => {
setTimeout(() => {
resolve({
title: '自定义转发标题'
})
}, 2000)
})
return {
title: '自定义转发标题',
path: '/page/user?id=123',
promise
}
}
})
onShareAppMessage(res){
var that = this
console.log(that.goods_data)
if(res.from==='button'){//分享按钮
return {
title:that.goods_data.share_title||that.goods_data.goods_name,
// path: '',
imageUrl:that.goods_data.share_img||that.goods_data.main_img,
success: function (res) {
if(res.errMsg == 'shareAppMessage:ok'){
console.log("成功",res)
}
},
fail:function(res){
console.log("失败",res)
}
}
}else{
return {
title:that.goods_data.share_title||that.goods_data.goods_name,
// path: '',
imageUrl:that.goods_data.share_img||that.goods_data.main_img,
success: function (res) {
if(res.errMsg == 'shareAppMessage:ok'){
console.log("成功",res)
}
},
fail:function(res){
console.log("失败",res)
}
}
}
}
文章来源:https://www.toymoban.com/news/detail-508223.html
到了这里,关于onShareAppMessage 微信小程序的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!