有没有发现,左上角有返回按钮了。原理简单,在你要分享的页面,分享配置时配置你的首页,并带上对应的参数,在首页 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') }, //事件处理函数 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') }, //事件处理函数 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) } } })