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

Vue: Detailed explanation of memory leaks

What is a memory leak? A memory leak means that a...

A collection of information about forms and form submission operations in HTML

Here we introduce the knowledge about form elemen...

mysql join query (left join, right join, inner join)

1. Common connections for mysql INNER JOIN (inner...

Implementation principle and configuration of MySql master-slave replication

Database read-write separation is an essential an...

Steps for Vue to use Ref to get components across levels

Vue uses Ref to get component instances across le...

About the usage and precautions of promise in javascript (recommended)

1. Promise description Promise is a standard buil...

Collection of 12 practical web online tools

1. Favicon.cc To create ico icon websites online,...

WeChat applet scroll-view realizes left-right linkage effect

WeChat applet uses scroll-view to achieve left-ri...

Sample code for implementing interface signature with Vue+Springboot

1. Implementation ideas The purpose of interface ...

Usage and execution process of http module in node

What is the role of http in node The responsibili...

The difference and reasons between the MySQL query conditions not in and in

Write a SQL first SELECT DISTINCT from_id FROM co...

Detailed explanation of Vue's sync modifier

Table of contents 1. Instructions 2. Modifiers 3....