当前位置:网站首页>小程序 多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() {
}
})
边栏推荐
- 远程办公工具分享|社区征文
- c# .net 工具生态
- Website with JS doesn't work in IE9 until the Developer Tools is activated
- 面试官:值为 nil 为什么不等于 nil ?
- [combinatorics] recursive equation (case where the non-homogeneous part is exponential | example where the non-homogeneous part is exponential)
- kubernetes资源对象介绍及常用命令(三)
- 自动渗透测试工具核心功能简述
- [RT thread] NXP rt10xx device driver framework -- Audio construction and use
- AcWing 4489. 最长子序列
- The difference between i++ and ++i: tell their differences easily
猜你喜欢
Introduction to SolidWorks gear design software tool geartrax
Talk about the design and implementation logic of payment process
Qt调节Win屏幕亮度和声音大小
QT adjust win screen brightness and sound size
QT learning diary 9 - dialog box
POM in idea XML graying solution
Leetcode 108 converts an ordered array into a binary search tree -- recursive method
Golang unit test, mock test and benchmark test
Vs2013 has blocked the installer, and ie10 needs to be installed
Type conversion, variable
随机推荐
[combinatorics] recursive equation (special solution form | special solution solving method | special solution example)
绝对定位时元素水平垂直居中
Create a new file from templates with bash script - create new file from templates with bash script
AcWing 3438. Number system conversion
Tensorboard quick start (pytoch uses tensorboard)
聊聊支付流程的设计与实现逻辑
Luogu: p1155 [noip2008 improvement group] double stack sorting (bipartite graph, simulation)
企业级自定义表单引擎解决方案(十一)--表单规则引擎1
[combinatorics] recursive equation (general solution structure of recursive equation with multiple roots | linear independent solution | general solution with multiple roots | solution example of recu
Electronic Science and technology 20th autumn "Microcomputer Principle and application" online assignment 2 [standard answer]
[RT thread] NXP rt10xx device driver framework -- pin construction and use
UE4 official charging resources, with a total price of several thousand
University of Electronic Science and technology, accounting computerization, spring 20 final exam [standard answer]
[RT thread] construction and use of --hwtimer of NXP rt10xx device driver framework
SWM32系列教程4-端口映射及串口应用
Five problems of database operation in commodity supermarket system
PHP returns 500 errors but no error log - PHP return 500 error but no error log
How to purchase Google colab members in China
c# . Net tool ecosystem
面试官:值为 nil 为什么不等于 nil ?