微信小程序點擊右上角按鈕分享頁面
/** * 用戶點擊右上角分享 */ onShareAppMessage: function(res) { if (res.from === 'button') { // 來自頁面內轉發按鈕 } return { title: "這個小程序真棒", path: "pages/start/start" } },
微信公眾平台教程點擊跳轉
222
頁面按鈕轉發,給按鈕添加open-type的share屬性,就會觸發轉發
<button open-type="share">分享名片</button>
!!!!
接下來如果你轉發名片的時候還想攜帶參數的話,就在跳轉的頁面后面加上參數的值
/** * 用戶點擊右上角分享 */ onShareAppMessage: function(res) { if (res.from === 'button') { // 來自頁面內轉發按鈕 } return { title: "這個小程序真好", path: 'pages/start/start?commentUserId=' + app.globalData.commentUserId } },
要想取到這個值就需要在跳轉那個頁面onload里面拿
onLoad: function(options) { //獲取分享轉發頁面時攜帶的參數 commentUserId =options.commentUserId; }