今天我分享另外一種方法。請看下面.gif;
有沒有發(fā)現(xiàn),左上角有返回按鈕了。原理簡單,在你要分享的頁面,分享配置時配置你的首頁,并帶上對應的參數(shù),在首頁 onLoad方法中可以獲取。代碼如下:
<!--index.wxml--> <view class="container"> <text>我是首頁</text> <button bindtap='goLogs'>go logsPage</button> </view> const app = getApp() Page({ data: { motto: 'Hello World', userInfo: {}, hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo') }, //事件處理函數(shù) goLogs: function() { wx.navigateTo({ url: '/pages/logs/logs' }) }, onLoad: function (options) { console.log(options) if (options.share_query){ wx.showLoading({ title: '我是從分享頁面進入的', }) setTimeout(function () { wx.hideLoading() wx.navigateTo({ url: '/pages/logs/logs', }) }, 2000) } } }) <!--logs.wxml--> <view class="container log-list"> <block wx:for="{{logs}}" wx:for-item="log"> <text class="log-item">{{index + 1}}. {{log}}</text> </block> </view> const app = getApp() Page({ data: { motto: 'Hello World', userInfo: {}, hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo') }, //事件處理函數(shù) goLogs: function() { wx.navigateTo({ url: '/pages/logs/logs' }) }, onLoad: function (options) { console.log(options) //判斷是否分享進入 if (options.share_query){ wx.showLoading({ title: '我是從分享頁面進入的', }) setTimeout(function () { wx.hideLoading() wx.navigateTo({ url: '/pages/logs/logs', }) }, 2000) } } })
相信看了本文案例你已經(jīng)掌握了方法,更多精彩請關注Gxl網(wǎng)其它相關文章!
推薦閱讀:
如何讓數(shù)據(jù)里html字段轉(zhuǎn)換為HTML標簽
前端如何向后臺傳送Json數(shù)據(jù)
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com