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 { ... }
}
