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

MySql sharing of null function usage

Functions about null in MySql IFNULL ISNULL NULLI...

How to install Docker on Windows 10 Home Edition

I recently used Docker to upgrade a project. I ha...

MySql index improves query speed common methods code examples

Use indexes to speed up queries 1. Introduction I...

Detailed steps for creating a Vue scaffolding project

vue scaffolding -> vue.cli Quickly create a la...

How to enable MySQL remote connection

For security reasons, MySql-Server only allows th...

How to introduce img images into Vue pages

When we learn HTML, the image tag <img> int...

How to Easily Remove Source Installed Packages in Linux

Step 1: Install Stow In this example, we are usin...

Detailed process of implementing the 2048 mini game in WeChat applet

Rendering Example Code Today we are going to use ...

How to solve the problem that Docker container has no vim command

Find the problem Today, when I tried to modify th...

Tutorial on downloading, installing, configuring and using MySQL under Windows

Overview of MySQL MySQL is a relational database ...

Detailed explanation of the use of Vue h function

Table of contents 1. Understanding 2. Use 1. h() ...

PNG Alpha Transparency in IE6 (Complete Collection)

Many people say that IE6 does not support PNG tra...

Example of how to configure cross-domain failure repair in nginx

Nginx cross-domain configuration does not take ef...

Pitfalls and solutions for upgrading MySQL 5.7.23 in CentOS 7

Preface Recently, I found a pitfall in upgrading ...