小程式同一頁面不同按鈕轉發不同樣式
阿新 • • 發佈:2018-12-12
wxml頁面
<button class="share-btn" open-type="share" id="1"></button>
<button class="share-btn" open-type="share" id="2"></button>
js頁面程式碼
onShareAppMessage: function (res) {
var that = this;
if (res.from == "button") {
if (res.target.id == 1) {
return {
title: '1要分享的標題',
path: '/pages/index/index',
success: function (res) {
}
}
}
if (res.target.id == 2) {
return {
title: '2要分享的標題',
path: '/pages/index/index',
success: function (res) {
}
}
}
}
//預設
else {
return {
title: '右上角要分享的標題',
path: '/pages/index/index',
success: function (res) {
}
}
}
}