用scroll-view做横向滚动时,给scroll-view设置了display:flex,子元素宽度固定,并且总长度超出scroll-view的宽度,但是发现滚动不了,并且子元素宽度被压缩了。
解决方法:
给scroll-view设置white-space: nowrap;
给子元素设置display: inline-block;
<scroll-view class="scroll" scroll-x="true">
<navigator class="item1" v-for="(item, index) in allSub" :key="index"></navigator>
</scroll-view>
.scroll {
white-space: nowrap;
}
.item1 {
margin-right: 30upx;
width:350upx;
height:180upx;
display: inline-block;
background-color: #FAFAFA;
}