How to implement tabs by WeChat Mini Programs
This article mainly introduces the relevant knowledge of "how to achieve tabs by WeChat Mini Programs". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "how to achieve tabs by WeChat Mini Programs" can help you solve the problem.
The realization method of WeChat Mini Programs's Tab
Foreword:
Students engaged in the front end must be familiar with tabs, whether they are written by themselves or in various UI frameworks. I think we have all used a lot of tabs and are clear enough about the principle of tabs. Let's implement the function of tabs in WeChat Mini Programs.
WeChat Mini Programs does not have its own tab component, but it does have a swiper component, so we use swiper to achieve the tab function.
Take a look at the effect picture first:
Implementation code:
Page code:
One, two, three, first screen, second screen, third screen.
Js Code:
Var app=getApp () Page ({data: {currentTab:0}, onLoad:function (options) {/ / parameters brought by page initialization options for page jump}, / / sliding switch swiperTab:function (e) {var that=this; that.setData ({currentTba:e.detail.current});}, / / Click to switch clickTab: function (e) {var that=this; if (this.data.currentTab = e.target.dataset.current) {return false } else {that.setData ({currentTab: e.target.dataset.current})})
Css Code:
.swiper-tab {width: 100%; border-bottom: 2rpx solid # ccc; text-align: center; height: 88rpx; line-height: 88rpx; font-weight: bold;} .swiper-tab-item {display: inline-block; width: 33.33%; color:red;} .active {color:aqua; border-bottom: 4rpx solid red;} about "how to implement WeChat Mini Programs tab", thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.