微信小程序開發(fā)之轉(zhuǎn)發(fā)分享功能
官網(wǎng)文檔:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html
第一種情況 點擊小程序轉(zhuǎn)發(fā)
不加入?yún)?shù)
//轉(zhuǎn)發(fā) onShareAppMessage: function() { let users = wx.getStorageSync('user'); if (res.from === 'button') {} return { title: '轉(zhuǎn)發(fā)', path: '/pages/index/index', success: function(res) {} } }
加入?yún)?shù)
//轉(zhuǎn)發(fā) onShareAppMessage: function() { let users = wx.getStorageSync('user'); if (res.from === 'button') {} return { title: '轉(zhuǎn)發(fā)', path: '/pages/index/index?from_uid=' + users.id, success: function(res) {} } }
第二種 分享
這個分享必須做成button 且加上 open-type="share"
不加入?yún)?shù)
onShareAppMessage: function (res) { if (res.from === 'button') { } return { title: '轉(zhuǎn)發(fā)', path: '/pages/index/community/topic/topic', success: function (res) { console.log('成功', res) } } }
加入?yún)?shù)
//轉(zhuǎn)發(fā) onShareAppMessage: function (res) { if (res.from === 'button') { } return { title: '轉(zhuǎn)發(fā)', path: '/pages/index/community/topic/topic?jsonStr=' + this.data.list, success: function (res) { console.log('成功', res) } } }
提醒:
這里轉(zhuǎn)發(fā)的參數(shù)要在onLoad 的options 運用
總結
以上所述是小編給大家介紹的微信小程序開發(fā)之轉(zhuǎn)發(fā)分享功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!