1)scroll-view实现
html结构如下:
<scroll-view class="scroll" scroll-x="true" style="height: 80px;">
<view class="item" v-for="(item,index) in 5" :key="index">
<view class="num">123</view>
</view>
</scroll-view>
scss样式如下:
.scroll{
overflow: hidden;
white-space: nowrap;
width: 100%;
background-color: #ccc;
.item{
display: inline-block;
height: 150rpx;
width: 250rpx;
background-color: pink;
margin-left: 20rpx;
}
}
2)view实现
html结构如下:
<view class="scroll">
<view class="total-item" v-for="(item,index) in 5" :key="index">
<view class="total-num">123</view>
</view>
</view>
scss样式如下:
.scroll{
overflow-x: auto;
white-space: nowrap;
width: 100%;
height: 180rpx;
background-color: #ccc;
.total-item{
display: inline-block;
height: 150rpx;
width: 250rpx;
background-color: pink;
margin-left: 20rpx;
}
}