How to return to the homepage of the sharing page of WeChat Mini Program

不言
Release: 2018-06-22 16:35:19
Original
2426 people have browsed it

This article mainly introduces the example of how to return to the home page of the sharing page of the WeChat applet. The editor thinks it is quite good, so I will share it with you now and give it as a reference. Let’s follow the editor and take a look.

When developing small programs, I found that after the page is shared, it is difficult for users to return to the home page through the shared page. (The official operation of WeChat is to click the three dots in the upper right corner, which will be displayed below the phone to return to the homepage). Many private solutions are to add a floating Home mark to the page yourself.

Today I will share another method. Please look at the .gif below;

Have you noticed that there is a return button in the upper left corner? The principle is simple. On the page you want to share, configure your homepage when sharing the configuration, and bring the corresponding parameters, which can be obtained in the onLoad method of the homepage. The code is as follows:

<!--index.wxml-->
<view class="container">
<text>我是首页</text>
 <button bindtap=&#39;goLogs&#39;>go logsPage</button>
</view>

const app = getApp()

Page({
 data: {
  motto: &#39;Hello World&#39;,
  userInfo: {},
  hasUserInfo: false,
  canIUse: wx.canIUse(&#39;button.open-type.getUserInfo&#39;)
 },
 //事件处理函数
 goLogs: function() {
  wx.navigateTo({
   url: &#39;/pages/logs/logs&#39;
  })
 },
 onLoad: function (options) {
  console.log(options)
  if (options.share_query){
   wx.showLoading({
    title: &#39;我是从分享页面进入的&#39;,
   })

   setTimeout(function () {
    wx.hideLoading()
    wx.navigateTo({
     url: &#39;/pages/logs/logs&#39;,
    })
   }, 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: &#39;Hello World&#39;,
  userInfo: {},
  hasUserInfo: false,
  canIUse: wx.canIUse(&#39;button.open-type.getUserInfo&#39;)
 },
 //事件处理函数
 goLogs: function() {
  wx.navigateTo({
   url: &#39;/pages/logs/logs&#39;
  })
 },
 onLoad: function (options) {
  console.log(options)
  //判断是否分享进入
  if (options.share_query){
   wx.showLoading({
    title: &#39;我是从分享页面进入的&#39;,
   })

   setTimeout(function () {
    wx.hideLoading()
    wx.navigateTo({
     url: &#39;/pages/logs/logs&#39;,
    })
   }, 2000)  
  }
  } 
})
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Bluetooth link in WeChat mini program

##Two methods to jump to the page in WeChat mini program

The above is the detailed content of How to return to the homepage of the sharing page of WeChat Mini Program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!