uniapp实现页面左滑右滑切换内容

uniapp + uview:使用uniapp的swiper和uview的tabs标签组合实现

Tabs 标签 - uview-plus 3.0 - uni-app UI框架

html 复制代码
<template>
    <view class="main">
        <view class="">
            <u-tabs :list="state.list" :current='state.current' @click="clickTab"></u-tabs>
        </view>
        <swiper :current='state.current' class="swiper-box" @change="swiperChange" :skip-hidden-item-layout='true'
            :duration='300'>
            <swiper-item v-for="item in state.list">
                <view>
                    {{item.name}}
                </view>
            </swiper-item>
        </swiper>
    </view>
</template>

<script setup>
    import {
        onMounted,
        onUnmounted,
        ref,
        reactive,
        computed,
        markRaw,
        getCurrentInstance,
        nextTick
    } from "vue";
    import {
        formatDateByDate,
        Toast
    } from "@/utils/utils.js";
    import store from "@/store/index.js";
    import {
        onPullDownRefresh,
        onReachBottom,
        onShow,
        onLoad
    } from "@dcloudio/uni-app";

    const {
        proxy
    } = getCurrentInstance();
    const state = reactive({
        list: [{
            name: '全部',
            id: ''
        },{
            name: '组筹备阶段',
            id: '1'
        },{
            name: '准备阶段',
            id: '2'
        },{
            name: '实施阶段',
            id: '3'
        },{
            name: '收尾阶段',
            id: '4'
        },],
        current: 0,
    });
    
    // tab切换
    const clickTab = (e) => {
        state.current = e.index
    }


    // 页面滑动
    const swiperChange = (e) => {
        state.current = e.detail.current
    }

</script>

<style scoped lang="less">
    .main {
        height: 100%;
        background: #EFF4FB;
        box-sizing: border-box;
        overflow: hidden;
        
        .swiper-box {
            height: calc(100vh - 224rpx);
            padding: 24rpx 24rpx;
            box-sizing: border-box;
        }

    }

</style>

相关推荐
一只程序熊7 小时前
【uniapp】errMsg: “navigateTo:fail timeout“
服务器·前端·uni-app
沙尘暴炒饭10 小时前
用uniapp在微信小程序实现画板(电子签名)功能,使用canvas实现功能
微信小程序·小程序·uni-app
DONSEE广东东信智能读卡器1 天前
蓝牙身份证阅读器使用Uniapp调用二次开发demo
javascript·uni-app·蓝牙·身份证阅读器
fakaifa1 天前
【开源版】likeshop上门家政系统PHP版全开源+uniapp前端
小程序·uni-app·php·家政小程序源码·家政服务小程序·源码下载·上门家政
阿諪諪1 天前
uniapp小程序中实现无缝衔接滚动效果
小程序·uni-app
七七小报1 天前
uniapp-商城-48-后台 分类数据添加修改弹窗bug
uni-app·bug
七七小报1 天前
uniapp-商城-50-后台 商家信息
uni-app
七七小报1 天前
uniapp-商城-51-后台 商家信息(logo处理)
java·服务器·windows·uni-app
七七小报2 天前
uniapp-商城-47-后台 分类数据的生成(通过数据)
uni-app