onShareAppMessage(Object object)
監(jiān)聽用戶點(diǎn)擊頁面內(nèi)轉(zhuǎn)發(fā)按鈕(button 組件 open-type=“share”)或右上角菜單“轉(zhuǎn)發(fā)”按鈕的行為,并自定義轉(zhuǎn)發(fā)內(nèi)容。
注意:只有定義了此事件處理函數(shù),右上角菜單才會顯示“轉(zhuǎn)發(fā)”按鈕文章來源地址http://www.zghlxwxcb.cn/news/detail-508223.html
Page({
onShareAppMessage() {
const promise = new Promise(resolve => {
setTimeout(() => {
resolve({
title: '自定義轉(zhuǎn)發(fā)標(biāo)題'
})
}, 2000)
})
return {
title: '自定義轉(zhuǎn)發(fā)標(biāo)題',
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)
}
}
}
}
文章來源:http://www.zghlxwxcb.cn/news/detail-508223.html
到了這里,關(guān)于onShareAppMessage 微信小程序的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!