当前位置:网站首页>小程序 多tab 多swiper + 每个tab分页
小程序 多tab 多swiper + 每个tab分页
2022-07-03 17:42:00 【一闪一闪亮晶晶,漫天都是小星星】
wxml:
<!-- header -->
<view class="flex flex-col flex-fv flex-fh">
<view class="flex flex-hb flex-ve text-9EA0A4 font32">
<view class="flex flex-ve" bindtap="changeTab">
<view class="mr40 line_height1 {
{ activeIndex == 0 ? 'text-2E3238 font48 font-w':'' }}" data-index="0">tab0</view>
<view class="mr40 line_height1 {
{ activeIndex == 1 ? 'text-2E3238 font48 font-w ':'' }}" data-index="1">tab1</view>
<view class="mr40 line_height1 {
{ activeIndex == 2 ? 'text-2E3238 font48 font-w':'' }}" data-index="2">tab2</view>
</view>
</view>
<view class="f1">
<swiper class="flex-fv" bindchange="bindSwiperChange" current="{
{ activeIndex }}">
<!-- tab0 -->
<swiper-item class="bg-red">
<scroll-view class="flex-fv" scroll-y bindscrolltolower="scrolltolower">
<block wx:for="{
{ tabData[0].list }}" wx:key="index">
<view></view>
</block>
</scroll-view>
</swiper-item>
<!-- tab1 -->
<swiper-item class="bg-green">
<scroll-view class="flex-fv" scroll-y bindscrolltolower="scrolltolower">
<block wx:for="{
{ tabData[1].list }}" wx:key="index">
<view></view>
</block>
</scroll-view>
</swiper-item>
<!-- tab2 -->
<swiper-item class="bg-red">
<scroll-view class="flex-fv" scroll-y bindscrolltolower="scrolltolower">
<block wx:for="{
{ tabData[2].list }}" wx:key="index">
<view style="height: 200rpx;" class="bg-white mt20">{
{ index }}</view>
</block>
</scroll-view>
</swiper-item>
</swiper>
</view>
</view>
js:
import { dateFormatStr } from "../../../utils/util";
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
tabData:[
{
list:[],
page:1
},
{
list:[],
page:2
},
{
list:[],
page:3
}
],
activeIndex:0,
page:1,
pageSize:10,
userInfo: {}, //登录人个人资料
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
userInfo: app.globalData.userInfo,
});
this.getList()
},
//tab切换
changeTab(e){
const { index } = e.target.dataset;
if(index >= 0){
this.setData({
activeIndex:index,
});
}
this.getList()
},
/**
* swiper切换
* @param {*} e
*/
bindSwiperChange:function(e){
var { current } = e.detail;
this.setData({
activeIndex:current,
});
this.getList()
},
/**
* 获取list
*/
getList(){
const { tabData,activeIndex,pageSize } = this.data
const addlist = []
this.setData({
[`tabData[${activeIndex}].list`]:tabData[activeIndex].list.concat(addlist)
})
},
/**
* 页面上拉触底事件的处理函数
*/
scrolltolower() {
const { tabData,activeIndex } = this.data
console.log('tabData:',tabData)
tabData[activeIndex].page++
this.getList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})边栏推荐
- Play with fancy special effects. This AE super kit is for you
- 【RT-Thread】nxp rt10xx 设备驱动框架之--Audio搭建和使用
- MinGW compile boost library
- Wechat applet for the first time
- Applet setting multi account debugging
- The difference between i++ and ++i: tell their differences easily
- Electronic technology 20th autumn "Introduction to machine manufacturing" online assignment 3 [standard answer]
- Where is the database account used when running SQL tasks in data warehouse tasks configured
- Is AI too slow to design pictures and draw illustrations? 3 sets of practical brushes to save you
- Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
猜你喜欢

POM in idea XML graying solution

Getting started with deops

Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code

聊聊支付流程的设计与实现逻辑

Leetcode 669 pruning binary search tree -- recursive method and iterative method

Golang单元测试、Mock测试以及基准测试

国内如何购买Google Colab会员

Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method

Records of long objects and long judgments in the stream of list
![[combinatorics] recursive equation (summary of the solution process of recursive equation | homogeneous | double root | non-homogeneous | characteristic root is 1 | exponential form | the bottom is th](/img/f1/c96c4a6d34e1ae971f492f4aed5a93.jpg)
[combinatorics] recursive equation (summary of the solution process of recursive equation | homogeneous | double root | non-homogeneous | characteristic root is 1 | exponential form | the bottom is th
随机推荐
Managing multiple selections with MVVM - managing multiple selections with MVVM
[combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
Basic grammar of interview (Part 2)
Kubernetes resource object introduction and common commands (4)
[RT thread] NXP rt10xx device driver framework -- Audio construction and use
Servlet specification Part II
Leetcode 669 pruning binary search tree -- recursive method and iterative method
SWM32系列教程4-端口映射及串口应用
聊聊支付流程的设计与实现逻辑
Luogu: p1155 [noip2008 improvement group] double stack sorting (bipartite graph, simulation)
Draw some simple graphics with MFC
Leetcode13. Roman numeral to integer (three solutions)
First day of rhcsa study
RDS数据库的监测页面在哪看?
Enterprise custom form engine solution (XI) -- form rule engine 1
一入“远程”终不悔,几人欢喜几人愁。| 社区征文
Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
TCP congestion control details | 3 design space
STM32 realizes 74HC595 control
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)