ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] # scroll-view ***** 可滚动视图区域。使用竖向滚动时,需要给[scroll-view](https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html)一个固定高度,通过 WXSS 设置 height。组件属性的长度单位默认为px,[2.4.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)起支持传入单位(rpx/px)。 <br> ## 水平滚动 **第一步:**给scroll-view添加**scroll-x="{{true}}"**属性 **第二步:**给scroll-view设计高度, 并给scroll-view添加 **white-space=‘ nowrap ’** 来强制scroll-view内容要在一行(默认内容抵达边界会换行) **第三步:**指定scroll-view里面的组件的类型为**行内块级标签:display: inline-block**(块级标签默认会换行) ``` <scroll-view scrollX> <view> </view> </scroll-view> ``` ***** <br> ## 垂直滚动 ***** **第一步:**给scroll-view添加scroll-y="{{true}}"属性 **第二步:**给scroll-view设计高度 > 注意:使用竖向滚动scroll-y时,需要给`scroll-view`一个固定高度,通过 WXSS 设置 height。 ``` <scroll-view scrollY> <view> </view> </scroll-view> ```