4***@qq.com
4***@qq.com
  • 发布:2025-05-06 14:41
  • 更新:2025-05-06 16:22
  • 阅读:104

uniapp swiper组件使用长列表时内部的fixed定位失效

分类:uni-app
<template>  
    <view class="container">  
        <swiper>  
            <swiper-item>  
                <view class="box"></view>  
                <view v-for="item in 20" :key="item" class="item">  
                    {{item}}  
                </view>  
            </swiper-item>  
        </swiper>  
    </view>  
</template>  
<script>  
    export default {}  
</script>  
<style lang="scss" scoped>  
    swiper {  
        height: 10000px;  
    }  

    .container {  
        height: 100vh;  

        .box {  
            position: fixed;  
            right: 0;  
            top: 200px;  
            width: 100rpx;  
            height: 100rpx;  
            border: 1rpx solid red;  
        }  

        .item {  
            padding: 50rpx;  
        }  
    }  
</style>
2025-05-06 14:41 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

hello , 这个效果是正常的,在swiper-item 上有position: absolute; 这个会导致还会在盒子内部

  • 4***@qq.com (作者)

    有没有解决办法

    2025-05-06 16:24

要回复问题请先登录注册