The code address is as follows:
http://www.demodashi.com/demo/14010.html
1, Preparatory work
Software environment: wechat developer tool
Official download address: https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html
1. Basic needs.
- tab switching based on swiper components
2. Case directory structure
2, Specific steps of program implementation
1.tab switch index.wxml code
<view class="continer"> <!--Content subject--> <swiper class="swiper" current="1" duration="200" bindchange="swiperChange" previous-margin="20px" next-margin="20px" style="height: {{winHeight}}px;"> <swiper-item> <view class="user-box" style="height: {{winHeight-40}}px;"> <view class="user-image"> <image class="image" src="https://www.geekxz.com/public/uploads/huaqu/team/logo.jpg" /> </view> <view class="user-info"> <view class="user-job">Unknown</view> <view class="user-name">Unknown</view> <view class="user-introduce">If you also embrace the dream and have unlimited talent, we OkYoung The team is looking forward to your joining.</view> <view class="joinin" bindtap="joinIn">Instant creation</view> </view> </view> </swiper-item> <swiper-item> <view class="user-box" style="height: {{winHeight-40}}px;"> <view class="user-image"> <image class="image" src="https://www.geekxz.com/public/uploads/huaqu/team/logo.jpg" /> </view> <view class="user-info"> <view class="user-job">Unknown</view> <view class="user-name">Unknown</view> <view class="user-introduce">If you also embrace the dream and have unlimited talent, we OkYoung The team is looking forward to your joining.</view> <view class="joinin" bindtap="joinIn">Instant creation</view> </view> </view> </swiper-item> <swiper-item> <view class="user-box" style="height: {{winHeight-40}}px;"> <view class="user-image"> <image class="image" src="https://www.geekxz.com/public/uploads/huaqu/team/logo.jpg" /> </view> <view class="user-info"> <view class="user-job">Unknown</view> <view class="user-name">Unknown</view> <view class="user-introduce">If you also embrace the dream and have unlimited talent, we OkYoung The team is looking forward to your joining.</view> <view class="joinin" bindtap="joinIn">Instant creation</view> </view> </view> </swiper-item> <swiper-item> <view class="user-box" style="height: {{winHeight-40}}px;"> <view class="user-image"> <image class="image" src="https://www.geekxz.com/public/uploads/huaqu/team/logo.jpg" /> </view> <view class="user-info"> <view class="user-job">Unknown</view> <view class="user-name">Unknown</view> <view class="user-introduce">If you also embrace the dream and have unlimited talent, we OkYoung The team is looking forward to your joining.</view> <view class="joinin" bindtap="joinIn">Instant creation</view> </view> </view> </swiper-item> </swiper> </view>
2. Part of index.wxss code
page { background-color: #0084ff; } .continer{ } swiper-item .user-box{ margin-top: 3%; margin-left: 20rpx; border-radius: 20rpx; border: 1rpx solid rgba(200, 200, 200, 0.1); box-shadow: 1px 1px 5px rgba(200, 200, 200, 0.4); background-color: #fff; } swiper-item .user-image image{ width:350rpx; height:350rpx; border-radius: 350rpx; margin-top: 20%; border: 1rpx solid rgba(200, 200, 200, 0.4); box-shadow: 1px 1px 5px rgba(200, 200, 200, 0.8); } .user-image{ margin: 0 25%; } .user-info { text-align: center; height: 240rpx; } .user-info view{ text-align: center; } .user-info .user-name{ margin-top: 80rpx; font-size: 40rpx; height: 80rpx; line-height: 80rpx; text-align: center; color: black; font-weight: 600; } .user-info .user-introduce{ width: 80%; margin: 0 auto; height: 60rpx; line-height: 60rpx; font-size: 36rpx; color: #5d5d5b; } .joinin{ width: 30%; margin: 0 auto; height: 60rpx; font-size: 32rpx; line-height: 60rpx; margin-top: 170rpx; color: #fff; border-radius: 60rpx; background-color: #118fff; }
3. Part of index.js logic code
a. Function realization of sliding switch
swichNav: function (e) { console.log(e); var that = this; if (this.data.currentTab === e.target.dataset.current) { return false; } else { that.setData({ currentTab: e.target.dataset.current, }) } },
3, Case operation rendering
4, Summary and remarks
There is no tab switching of wechat applet based on swiper component
The code address is as follows:
http://www.demodashi.com/demo/14010.html
Note: the copyright of this article belongs to the author and is published by the demo master. Reprint is refused. Reprint requires the authorization of the author