微信小程序使用scroll-view问题

397 阅读1分钟

使用微信小程序的scroll-view的的注意事项

  • 添加了enable-flex="true"之后,再在css为scroll-view里面设置display: flex才生效
<scroll-view class="scroll" scroll-x="true"  enable-flex="true">
    <view ></view>
</scroll-view>

.scroll {
    display: flex;
}

  • scroll-view是横向滚动时,设置display: flex,导致内容显示不完全问题, 给scroll-view设置css:white-space:nowrap可以解决
<scroll-view class="scroll" scroll-x="true"  enable-flex="true">
    <view ></view>
</scroll-view>

.scroll {
    display: flex;
    white-space:nowrap;
}