1. 스크롤뷰 컴포넌트의 가로 스크롤 구현
WeChat 공식 문서에 따라 스크롤-x 및 활성화-플렉스를 추가한 후에도 여전히 가로 스크롤을 달성할 수 없습니다.
1. 스크롤 및 스타일을 허용하도록 스크롤 보기 구성 요소에 스크롤-x를 추가합니다: 디스플레이: 인라인 블록;
2. 추가 스크롤해야 하는 뷰 요소 Style: white-space: nowrap;
wxml 코드:
<scroll-view class="content1" scroll-x>
<view>A</view>
<view>B</view>
<view>C</view>
</scroll-view>
wxss 코드:
view{
width: 200rpx;
height: 200rpx;
text-align: center;
line-height: 200rpx;
/* 解决横向滚动问题 */
display: inline-block; /* 第一步 */
}
view:first-child{
background-color: lightgreen;
}
view:nth-child(2){
background-color: lightskyblue;
}
view:last-child{
background-color: lightpink;
}
.content1{
height: 200rpx;
width: 240rpx;
border: 1px solid red;
white-space: nowrap; /* 第二步 */
}
렌더링: