WeChat applet custom tabBar step record

WeChat applet custom tabBar step record

1. Introduction

Many times, the tabBar that comes with the mini program cannot meet the project requirements, so we need to customize the tabBar. But after searching for a long time on the Internet, most of the problems I found were flickering when switching. Fortunately, starting from the base library 2.5.0, you can officially use custom tabBar.

2. Customize tabBar style

As shown in the figure below, we need a tabBar that displays "Home", "My", and a page that can be clicked to jump to the release. This style, the native one cannot meet the needs, so you can only customize the tabBar.

3. Introduce custom-tab-bar and related configuration

3.1. As shown in the figure below, import custom-tab-bar [Download] into the project root directory.

3.2. Configure the switching tabbar in app.json and set "custom": true, then set the base library to 2.5.0

3.3. Use custom TabBar and add the following code in onShow of the switched TabBar interface. For example, the home page sets selected: 0, and mine sets selected: 2. Because selected: 1 is a special jump, when you click the plus icon, it no longer switches the tabbar, but directly jumps to the publishing interface.

/**
   * Life cycle function--monitor page display*/
  onShow: function () {
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      console.log('Set selected item 0')
      this.getTabBar().setData({
        selected: 0
      })
    }
  },

4. Complete Demo

Real machine testing is available and it is very easy to use. 【Complete Demo download address】

Summarize

This is the end of this article about how to customize the tabBar of WeChat Mini Program. For more relevant content about customizing the tabBar of Mini Program, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • WeChat Mini Program official dynamic custom bottom tabBar example
  • Detailed explanation of WeChat applet custom tabBar adaptation in uni-app
  • Detailed explanation of the development of WeChat applet custom tabBar component
  • How to customize the color of the top border of the WeChat applet tabbar
  • Implementation of custom tabBar in WeChat applet development
  • WeChat applet custom sliding top TabBar tab to achieve page switching function example
  • WeChat applet custom tabBar stepping practice record
  • WeChat applet custom tabbar custom-tab-bar 6s does not come out solution (cover-view is incompatible)
  • WeChat applet custom menu switch bar tabbar component code example
  • WeChat applet custom tabbar component

<<:  Summary of Linux date command knowledge points

>>:  MySQL5.7.27-winx64 version win10 download and installation tutorial diagram

Recommend

MySQL GROUP_CONCAT limitation solution

effect: The GROUP_CONCAT function can concatenate...

Summary of commonly used CSS encapsulation methods

1. pc-reset PC style initialization /* normalize....

14 Ways to Create Website Content That Engages Your Visitors

When I surf the Net, I often see web sites filled...

VMware Workstation installation Linux system

From getting started to becoming a novice, the Li...

Implementation of tomcat deployment project and integration with IDEA

Table of contents 3 ways to deploy projects with ...

CSS layout tutorial: How to achieve vertical centering

Preface I have been summarizing my front-end know...

A brief discussion on several ways to pass parameters in react routing

The first parameter passing method is dynamic rou...

Implementation example of video player based on Vue

When the existing video player cannot meet the ne...

Detailed explanation of JavaScript's built-in Date object

Table of contents Date Object Creating a Date Obj...

Detailed explanation of the usage and difference between nohup and & in Linux

Example: We use the Python code loop_hello.py as ...

ftp remotely connect to Linux via SSH

First install ssh in Linux, taking centos as an e...

CSS draw a lollipop example code

Background: Make a little progress every day, acc...