微信小程式點選右上解分享動態獲取title
阿新 • • 發佈:2020-09-07
wxml:(父級頁面)
<viewclass="pageLiflex"catchtap="toInstitute"data-name="{{item.shop_name}}"data-id="{{item.id}}"> <imagesrc='{{item.headimg}}'mode='aspectFill'></image> <viewclass="pagePresub"> <textclass="titf32">{{item.shop_name}}</text> <viewclass="page_textflex"> <textwx:for="{{item.sports}}"wx:if="{{idx<4}}"wx:for-index="idx"wx:for-item="item2">{{item2.sport_name}}</text> </view> <textclass="phone">聯絡電話:{{item.phone}}</text> <textclass="add">瀏覽:{{item.sort}}</text> <textclass="add">{{item.address}}</text> </view> </view>wxjs:(父級頁面)
toInstitute: function(e) { let share_title=e.currentTarget.dataset.name let id = e.currentTarget.dataset.id wx.navigateTo({ url: '/pages/newPage/institute/index?share_title=' + share_title + '&id=' + id }) },
wxjs:(子頁面)
data: { id: 0, shareTitle:'' }, onLoad: function (options) {this.data.id = options.id this.data.shareTitle=options.share_title console.log(this.data.shareTitle) console.log(options.share_title) } /** * 使用者點選右上角分享 */ onShareAppMessage: function (options) { console.log(options.share_title) // 使用者點選了“轉發”按鈕 return { title:this.data.shareTitle } },