WeChat applet realizes simple tab switching effect

WeChat applet realizes simple tab switching effect

This article shares the specific code for WeChat applet to achieve Tab switching effect for your reference. The specific content is as follows

How to use

The code is as follows (example):

Define a status status

data: {
   status: 0,
  },

The code is as follows (example):

When clicking on the switch, use the status to switch according to the index subscript to achieve

js code:

handtab(e) {
    console.log(e);
    let index = e.currentTarget.dataset.index
    console.log(index);
    this.setData({
      currentIndex: index,
      status: e.currentTarget.dataset.index
      //When clicking on the switch, use the status to switch according to the index subscript})
  },

wxml code:

<view>
  <block wx:for="{{data}}" wx-key="index" class="list_top">
    <view data-index="{{index}}" class="list_one {{index==currentIndex?'active':''}}" bindtap="handtab">{{item.name}}
    </view>
  </block>
  <block wx:for="{{shopList}}" wx:key="index">
    <view class="shopList_box" bindtap="handDetail" data-id="{{item.goods_id}}" wx:if="{{status==0}}">
    //Use wx:if status == 0 in wxml to change the tab switch to show and hide the following part <view class="shopList_left">
        <image src="{{item.goods_big_logo}}"></image>
      </view>
      <view class="shopList_right"> <text class="right">{{item.goods_name}}</text>
        <text class="price">¥{{item.goods_price}}</text>
      </view>
    </view>
  </block>
  <block>
  //status==1<view wx:if="{{status==1}}">2</view>
  </block>
  <block>
   //status==2<view wx:if="{{status==2}}">3</view>
  </block>
</view>

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • WeChat applet development to achieve tab (TabBar at the top of the window) page switching
  • WeChat applet swiper makes tab switching with source code
  • WeChat applet tab page switching updates data
  • WeChat applet realizes the tab switching effect
  • WeChat applet development tab (TabBar at the bottom of the window) page switching
  • WeChat applet realizes tab switching effect
  • WeChat applet scroll tab to achieve left and right sliding switching
  • WeChat applet realizes the combination of tab and swiper switching effect
  • WeChat applet implements tab page switching function
  • WeChat applet realizes the effect of switching Didi navigation tab

<<:  How to implement mysql database backup in golang

>>:  How to set static IP in centOS7 NET mode

Recommend

CSS realizes the scene analysis of semi-transparent border and multiple border

Scenario 1: To achieve a semi-transparent border:...

Use Docker Compose to quickly deploy ELK (tested and effective)

Table of contents 1. Overview 1.1 Definition 1.2 ...

Detailed steps for debugging VUE projects in IDEA

To debug js code, you need to write debugger in t...

MySQL 5.6 root password modification tutorial

1. After installing MySQL 5.6, it cannot be enabl...

In-depth study of MySQL composite index

A composite index (also called a joint index) is ...

MySQL 8.0.20 installation and configuration tutorial under Docker

Docker installs MySQL version 8.0.20 for your ref...

Solve the problem of ugly blue border after adding hyperlink to html image img

HTML img produces an ugly blue border after addin...

Docker-compose image release process analysis of springboot project

Introduction The Docker-Compose project is an off...

js canvas realizes random particle effects

This article example shares the specific code of ...

Descending Index in MySQL 8.0

Preface I believe everyone knows that indexes are...

Vue uses OSS to upload pictures or attachments

Use OSS to upload pictures or attachments in vue ...

Detailed explanation of the difference between Vue life cycle

Life cycle classification Each component of vue i...

Docker deploys Macvlan to achieve cross-host network communication

Basic concepts: Macvlan working principle: Macvla...