swiper 组件中设置横向超出可滚动

swiper组件有overflow: hidden属性
普通设置盒子
overflow-x: auto;
white-space: nowrap;
width: 582rpx;
不生效

需要在外面包裹一个
<scroll-view :scroll-x="true" @touchmove.stop class="scroll-x"> </scroll-view>
:scroll-x="true"设置横向滑动 @touchmove.stop阻止冒泡滑动swiper scroll-x设置宽度

注意 :
如果croll-view 内的盒子有 display: flex;属性 避免子盒子挤压
需要加上 white-space: nowrap;

或者子盒子 flex-shrink:0

   <scroll-view :scroll-x="true" @touchmove.stop class="scroll-x">
                <view  class="relation-list">
                  <view
                    v-for="(item, index) in personData.guanxi"
                    :key="index"
                    class="relation-list-item"
                  ></view>
              </scroll-view>

.scroll-x{
    width: 660rpx;
  }
  .relation-list {
    display: flex;
    white-space: nowrap;
    .relation-list-item { ... }
  }


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容