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>

相关推荐
陆康永6 小时前
uniapp-x vue 特性
javascript·vue.js·uni-app
前端_yu小白6 小时前
uniapp路由跳转导致页面堆积问题
前端·uni-app·页面跳转·返回
join810 小时前
解决uni-app授权弹框华为审核拒绝
uni-app
IT199510 小时前
uniapp笔记-底部和首部标签页菜单生成
笔记·uni-app
是小蟹呀^21 小时前
uni-app+SpringBoot: 前端传参,后端如何接收参数
spring boot·uni-app
月白星兮1 天前
IOS兼容 - uniapp ios固定定位失效与刘海屏的坑
ios·uni-app·cocoa
努力做大神1 天前
uniapp vue3项目定义全局变量,切换底部babar时根据条件刷新页面
uni-app·vue3
hunzi_11 天前
来客推商城V3多用户uni-app商城源码怎么样?
uni-app
不法1 天前
uniapp APP权限弹框
uni-app