uniApp实现上下联动

<view>
    <!-- 头部 -->
    <view class="flex flex-row mt-2" >
        <view v-for="(item,index) of tabList" :key="index" class="flex-1 text-center font-weight-bold" :class="tabIndex == index?'text-main font-lg ':'text-dark font-md'"  @click="changeTab(index)">{{item.name}}</view>
    </view>
    <!-- 好友列表 -->
     <swiper :current="tabIndex" :style="'height:'+scrollH+'px;'" @change="change">
         <swiper-item v-for="(item,index) of tabList" :key='index'>
             <block v-for="(inneritem,innerindex) of friendsList" :key='innerindex' >
             <view class="flex flex-row p-2 border-bottom align-center" >
     <image :src="item.avatar" style="width: 82rpx; height: 81rpx;" class="rounded-circle"></image>
     <view class="pl-2  w-100">
         <view>{{item.name}}</view>
         <view class="minBg text-white text-center flex justify-center align-center" style="width: 80rpx; height: 40rpx; border-radius: 20rpx;">
             <text class="iconfont icon-nv font-smaller"></text>
             <text>{{item.age}}</text>
         </view>
     </view>
     <view class=" flex justify-end rounded-circle bg-secondary" style="width: 50rpx; height: 50rpx;">
         <text class="uni-icon uni-icon-checkbox-filled text-light"></text>
     </view>
 </view>
             </block>
         </swiper-item>
     </swiper>
    
</view>
     //js部分
data() {
        return {
            scrollH:'',
            tabIndex: 1,
            tabList: [{
                name: '互关',
                id: 0
            }, {
                name: '关注',
                id: 0
            }, {
                name: '粉丝',
                id: 0
            }],
            friendsList: [{
                    avatar: '../../static/2.jpg',
                    name: 'Heroine',
                    age: 21,
            
                },
                {
                    avatar: '../../static/2.jpg',
                    name: 'Heroine',
                    age: 21,
            
                }, {
                    avatar: '../../static/2.jpg',
                    name: 'Heroine',
                    age: 21,
            
                } , {
                    avatar: '../../static/2.jpg',
                    name: 'Heroine',
                    age: 21,
            
                }
            ]
        }
    },
    **//js部分**
    onLoad(){
        const that = this
        uni.getSystemInfo({
            success: function (res) {
                console.log('res',res)
              that.scrollH = res.windowWidth
            }
        });
    },
    methods: {
        //切换tab
        changeTab(index){
            console.log(index,'index')
            this.tabIndex = index
        },
        //swiper部分滑动
        change(e){
            let index = e.detail.current
             this.changeTab(index)
        }8
        
    }
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值