A simple method to deal with the tabBar at the bottom of WeChat applet blocking content

A simple method to deal with the tabBar at the bottom of WeChat applet blocking content

After configuring the tabBar in the WeChat applet, important content will be blocked, and different models such as iPhoneX may have a blank space below as shown below. The tricky thing is that the blank space at the bottom of the page will also display the page, so it is necessary to obtain the height of the blocked area.

It can be seen that there will be an extra blank space under the iPhoneX, which will also increase the occlusion of the tabBar. Various information about the model can be obtained through wx.getSystemInfoSync().

Among them, screenHeight is the screen height, and the bottom property of safeArea will automatically calculate the safe area, which is the vertical coordinate of the useful area after removing the blank area under the tabBar.

This way you can easily calculate the height of the tabBar:

const res = wx.getSystemInfoSync()
const { screenHeight, safeArea: { bottom } } = res
console.log('resHeight',res);
if (screenHeight && bottom){
  let safeBottom = screenHeight - bottom
  this.setData({
    height: 48 + safeBottom
  })
}

Among them, 48 is the height of our custom tab bar, so that we can customize a component to set the height to support the bottom, and then introduce the tabBar at the end of the page. However, when using webview, the webview will fill the entire page, resulting in failure to fill the blank below. At this time, the height of the obstruction can be passed to the webview page through the URL query and then set padding-bottom for the page.

Appendix: Main properties of tabBar:


The properties of each item in tabBar are as follows:

Summarize

This is the end of this article about how to deal with the content obstruction of the tabBar at the bottom of the WeChat mini-program. For more information about the content obstruction of the tabBar at the bottom of the mini-program, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • WeChat Mini Program (Part 3) Detailed Introduction to TabBar Bottom Navigation
  • WeChat applet development to achieve tab (TabBar at the top of the window) page switching
  • WeChat applet development: Tabbar example detailed explanation
  • WeChat applet creates a new login page and hides the tabBar
  • WeChat Mini Program official dynamic custom bottom tabBar example
  • Detailed explanation of WeChat applet custom tabBar adaptation in uni-app
  • Implementation of tabbar icons and colors in WeChat applet development
  • WeChat applet development tab (TabBar at the bottom of the window) page switching
  • WeChat applet tabBar usage example detailed explanation
  • Detailed explanation of the development of WeChat applet custom tabBar component

<<:  Detailed explanation of MySQL 5.7 MGR single master determination master node method

>>:  Centos8 bridge static IP configuration method in VMware virtual machine

Recommend

Implementation example of Vue+Element+Springboot image upload

Recently, I happened to be in touch with the vue+...

Learn more about MySQL indexes

1. Indexing principle Indexes are used to quickly...

MySQL login and exit command format

The command format for mysql login is: mysql -h [...

Example of implementing grouping and deduplication in MySQL table join query

Table of contents Business Logic Data table struc...

mysql5.7 installation and configuration tutorial under Centos7.3

This article shares the MySQL 5.7 installation an...

Solution to Apache cross-domain resource access error

In many cases, large and medium-sized websites wi...

MySQL loop inserts tens of millions of data

1. Create a test table CREATE TABLE `mysql_genara...

Interpretation of Vue component registration method

Table of contents Overview 1. Global Registration...

Graphic tutorial on installing tomcat8 on centos7.X Linux system

1. Create the tomcat installation path mkdir /usr...

How to build a React project with Vite

Table of contents Preface Create a Vite project R...

5 Tips for Protecting Your MySQL Data Warehouse

Aggregating data from various sources allows the ...

An article to help you thoroughly understand position calculation in js

Table of contents introduction scroll Element.scr...

JavaScript recursion detailed

Table of contents 1. What is recursion? 2. Solve ...

Example of asynchronous file upload in html

Copy code The code is as follows: <form action...

Control the vertical center of the text in the HTML text box through CSS

When the height attribute of Text is defined, the ...