微信小程序分享功能實現(xiàn)教程,小程序分享功能如何實現(xiàn)
應用小程序時,需要將小程序分享到朋友圈,或者微信群,那么小程序分享功能要如何實現(xiàn),下面給大家介紹。
WXML 代碼
<view class='carDesc carDesc1'> <text>金氏養(yǎng)豬場</text> <button class='share' id="shareBtn" open-type="share" type="primary" hover-class="other-button-hover"> <image src='../../images/share.png'></image> 分享 </button> </view>
js代碼
onShareAppMessage: function (ops) { if (ops.from === 'button') { // 來自頁面內(nèi)轉發(fā)按鈕 console.log(ops.target) } return { title: 'xx小程序', path: 'pages/index/index', success: function (res) { // 轉發(fā)成功 console.log("轉發(fā)成功:" + JSON.stringify(res)); }, fail: function (res) { // 轉發(fā)失敗 console.log("轉發(fā)失敗:" + JSON.stringify(res)); } } }
回調(diào)結果:
回調(diào)類型 | errMsg | 說明 |
---|---|---|
success | shareAppMessage:ok | 轉發(fā)成功 |
fail | shareAppMessage:fail cancel | 用戶取消轉發(fā) |
fail | shareAppMessage:fail (detail message) | 轉發(fā)失敗,其中 detail message 為詳細失敗信息 |
HiShop小程序工具提供多類型商城/門店小程序制作,可視化編輯 1秒生成5步上線。通過拖拽、拼接模塊布局小程序商城頁面,所看即所得,只需要美工就能做出精美商城。
更多小程序資訊,盡在:hydrodefense.cn/xiaocx/