微信小程序?qū)崿F(xiàn)頁面分享onShareAppMessage
更新時(shí)間:2019年08月12日 10:31:11 作者:意外金喜
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)頁面分享onShareAppMessage,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
效果
js
let app = getApp(); Page({ data: { img: "/images/1.jpg" }, onLoad() { }, showShareMenu() { wx.showShareMenu(); console.log("顯示了當(dāng)前頁面的轉(zhuǎn)發(fā)按鈕"); }, hideShareMenu() { wx.hideShareMenu(); console.log("隱藏了當(dāng)前頁面的轉(zhuǎn)發(fā)按鈕"); }, onShareAppMessage: (res) => { if (res.from === 'button') { console.log("來自頁面內(nèi)轉(zhuǎn)發(fā)按鈕"); console.log(res.target); } else { console.log("來自右上角轉(zhuǎn)發(fā)菜單") } return { title: '妹子圖片', path: '/pages/share/share?id=123', imageUrl: "/images/1.jpg", success: (res) => { console.log("轉(zhuǎn)發(fā)成功", res); }, fail: (res) => { console.log("轉(zhuǎn)發(fā)失敗", res); } } } })
html
<view class="view"> <image class="cover-9" src="{{img}}" bindtap="img"></image> <view class="window-1"> <button type="default" id="open" bindtap="showShareMenu">開啟分享</button> <button type="warn" id="close" bindtap="hideShareMenu">關(guān)閉分享</button> </view> <button type="primary" open-type="share" data-name="pageShare" id="share">點(diǎn)擊分享</button> </view>
css
page{ height: 100%; } .view{ width: 100%; height: 100%; } .window-1{ display: flex; flex-direction: row; margin: 20rpx 0; } .cover-9{ width: 688rpx; height: 75%; margin: 0 30rpx; border:2rpx solid; border-radius:5px; } button{ margin: 0 10rpx; width: 100%; } #share{ width: 730rpx; }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
解決前端接收 type:"application/octet-stream" 格
前端接收 type: “application/octet-stream“ 格式的數(shù)據(jù)并下載,還有后端既返回octet-stream還返回JSON數(shù)據(jù)時(shí)的處理方法,今天給大家分享前端接收 type:"application/octet-stream" 格式的數(shù)據(jù)并下載(解決后端返回不唯一問題)的解決方案,感興趣的朋友一起看看吧2023-12-12微信小程序云開發(fā)實(shí)現(xiàn)云數(shù)據(jù)庫讀寫權(quán)限
這篇文章主要為大家詳細(xì)介紹了微信小程序云開發(fā)實(shí)現(xiàn)云數(shù)據(jù)庫讀寫權(quán)限,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-05-05JS、jquery實(shí)現(xiàn)幾分鐘前、幾小時(shí)前、幾天前等時(shí)間差顯示效果的代碼實(shí)例分享
在新浪微博首頁看到每條微博后邊顯示的時(shí)間并不是標(biāo)準(zhǔn)的年-月-日格式,而是經(jīng)過換算的時(shí)間差,如:發(fā)表于5分鐘前、發(fā)表于“2小時(shí)前”,比起標(biāo)準(zhǔn)的時(shí)間顯示格式,貌似更加直觀和人性化2014-04-04