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