1. IntroductionMany 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 styleAs 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 configuration3.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 DemoReal machine testing is available and it is very easy to use. 【Complete Demo download address】 SummarizeThis 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:
|
<<: Summary of Linux date command knowledge points
>>: MySQL5.7.27-winx64 version win10 download and installation tutorial diagram
Table of contents The use of Vue's keep-alive...
What are slots? We know that in Vue, nothing can ...
question How to modify CSS pseudo-class style wit...
One-click execution To install Python 3.8 in a vi...
Table of contents Boolean Type Number Types Strin...
Preface When writing front-end pages, we often us...
Table of contents From father to son: 1. In the s...
This article deploys Jenkins+Maven+SVN+Tomcat thr...
I've been using Bootstrap to develop a websit...
background Today, while cooperating with other pr...
MySQL escape Escape means the original semantics ...
Table of contents 1. TypeScript is introduced int...
This article shares the specific code of JavaScri...
Simple example of HTML checkbox and radio style b...