1.小程序分享功能實(shí)現(xiàn)方式
小程序分享功能有兩種方式,監(jiān)聽用戶點(diǎn)擊頁面內(nèi)轉(zhuǎn)發(fā)按鈕( 組件 open-type=“share”)或右上角菜單“轉(zhuǎn)發(fā)”按鈕的行為,并自定義轉(zhuǎn)發(fā)內(nèi)容。
使用微信小程序的分享功能需要定義onShareAppMessage(Object object)函數(shù),存在該函數(shù)分享功能才能被觸發(fā)
官網(wǎng)介紹如下:
2.定義觸發(fā)分享功能的icon按鈕
注意設(shè)置open-type="share"用于觸發(fā)分享功能
<button class="iconfont icon-yaoqing" style="font-size:65rpx;width:100%" open-type="share"></button>
1
效果查看
可以看到icon顯示在按鈕上了,但存在自帶樣式,有點(diǎn)丑,需要去掉
我的按鈕存在于student-orther-icon下,將該class下的按鈕樣式清除?
/* button自帶樣式清除 */
.student-orther-icon button::after {
? border: none !important;
? padding: 0 !important;
? margin: 0 !important;
}.student-orther-icon button {
? background-color: transparent !important;
? padding: 0 !important;
? line-height: inherit !important;
? margin: 0 !important;
? width: auto !important;
? font-weight: 500 !important;
? border-radius: none !important;
}
?
? //分享功能
? onShareAppMessage(res){
? ? //判斷觸發(fā)的方式是否為按鈕
? ? if(res.from=="button"){
? ? ? //參數(shù)
? ? ? let uid = "111";
? ? ? return{
? ? ? ? title:"標(biāo)題",
? ? ? ? path:"/pages/dynamic/dynamic?uid="+uid
? ? ? }
? ? }
? }
?
文章來源:http://www.zghlxwxcb.cn/news/detail-496137.html
就這樣,分享功能就簡簡單單的實(shí)現(xiàn)了?文章來源地址http://www.zghlxwxcb.cn/news/detail-496137.html
到了這里,關(guān)于微信小程序點(diǎn)擊icon實(shí)現(xiàn)分享功能的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!