


Example of how WeChat applet implements the non-swiper effect of the normal tab at the top
This article mainly introduces in detail the WeChat applet to achieve the effect of ordinary tabs at the top, which is not swiper, and has certain reference value. Interested friends can refer to it
Background: Some time ago I wrote a small program to grab red envelopes, which involved the top tab and pulled it out.
Rendering:
The code is directly below:
wxml:
<view class="navbar"> <text wx:for="{{navbar}}" data-index="{{index}}" class="item {{currentIndex==index?'active':''}}" bindtap="navbarTab" wx:key="unique">{{item}}</text> </view> <view hidden="{{currentIndex!==0}}"> </view> <view hidden="{{currentIndex!==1}}"> </view>
wxss:
.navbar{ display: flex; width: 100%; flex-direction: row; line-height: 80rpx; position: fixed; top: 0; } .navbar .item{ flex: auto; font-size: 30rpx; text-align: center; background: #fff; font-weight: bold; } .navbar .item.active{ color: #36DB2C; position: relative; } .navbar .item.active::after{ content: ""; display: block; position: absolute; height: 4rpx; bottom: 0; left: 0; right: 0; background: #36DB2C; }
js:
data: { navbar: ["我发出的", "我收到的"], currentIndex: 0,//tabbar索引 }, navbarTab: function (e) { this.setData({ currentIndex: e.currentTarget.dataset.index }); },
The above is the basic code of the implementation process, omitting the intermediate content code. The top number is recycled and can be set according to your actual needs.
The above is the detailed content of Example of how WeChat applet implements the non-swiper effect of the normal tab at the top. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools