当前位置:网站首页>短视频商城系统,scroll-view如何自适应页面剩余高度
短视频商城系统,scroll-view如何自适应页面剩余高度
2022-06-24 19:31:00 【云豹网络科技】
短视频商城系统,scroll-view如何自适应页面剩余高度
onLoad(options){
uni.getSystemInfo({
success: (res) => {
// 获取手机状态栏高度
this.statusBarHeight = res.statusBarHeight;
this.scrollviewHeight = `calc(100vh - 98rpx - 110rpx - ${
this.statusBarHeight}px)`;
}
});
}
给标签添加行内样式:
<scroll-view class="chat-main"
scroll-y="true"
:scroll-into-view="scrollToView"
:scroll-with-animation="needScrollAnimation"
@scrolltoupper="debounce"
:style="{height:scrollviewHeight}">
</scroll-view>
但这种方法需要使用js计算不太简便,可以使用flex布局,将主轴设为y轴,随后指定另外两个组件的高度,scroll-view区域使用flex:1高度自适应即可。需要注意的是除了自适应区域以外的元素一定要指定高度,如果没有确定的高度可以指定相对高度。还有就是page是小程序默认包裹在最外层的标签,也要指定高度height:100%
<view class="box">
<top-bar class="box-head"></top-bar>
<scroll-view class="box-scroll"></scroll-view>
<bottom-bar class="box-bottom"></bottom-bar>
</view>
page{
height:100%;
}
.box {
display: flex;
flex-direction:column;
height:100vh; /*高度必须指定 或者写成100%*/
overflow:hidden;
}
.box-head {
flex-shrink: 0;
height: 55px;
}
.box-scroll {
flex: 1;
overflow: scroll; /*必须写这一条*/
height: 1px;
}
.box-bottom {
height:49px;
}
以上就是短视频商城系统,scroll-view如何自适应页面剩余高度, 更多内容欢迎关注之后的文章
边栏推荐
- leetcode:45. Jumping game II [classic greed]
- Collective search + drawing creation
- Drag drag drag
- openGauss内核:简单查询的执行
- Suspend component and asynchronous component
- Machine learning: gradient descent method
- A deep learning model for urban traffic flow prediction with traffic events mined from twitter
- TCP RTT测量妙计
- KT6368A蓝牙芯片的主从机之前透传功能说明,2.4G跳频自动连接
- Getting started with typescript
猜你喜欢

cv2导包时报Could not find a version that satisfies the requirement cv2 (from versions: none)

Binary search tree template

KT6368A蓝牙双模透传芯片软件版本选型说明
![[notes of Wu Enda] convolutional neural network](/img/19/2cac17010c29cbd5ba245de105d6c1.png)
[notes of Wu Enda] convolutional neural network

Filtered data analysis

Flutter 库冲突问题解决

KT6368A蓝牙芯片的主从机之前透传功能说明,2.4G跳频自动连接
![leetcode:55. Jumping game [classic greed]](/img/da/16e4ab51320d68bd1ade0eb0a2dbc2.png)
leetcode:55. Jumping game [classic greed]

CV2 package guide times could not find a version that satisfies the requirement CV2 (from versions: none)

Notes on writing questions (18) -- binary tree: common ancestor problem
随机推荐
排查到解决问题的过程:浏览器突然无法访问网页,错误代码:0x80004005,最终定位:“电脑打开热点,电脑就不能上网了”
壹沓科技签约七匹狼,助力「中国男装领导者」数字化转型
Flutter: Unsupported value: false/true
Réduire le PIP à la version spécifiée (mettre à jour le PIP avec pycharm avant de le réduire à la version originale)
拖动拖动拖动
如何抓手机的包进行分析,Fiddler神器或许能帮到您!
Yida technology signed a contract with seven wolves to help the digital transformation of "Chinese men's wear leader"
leetcode:1504. 统计全 1 子矩形的个数
旅行商问题(TSP)的相关论文总结
C language - keyword 1
滤波数据分析
[untitled]
02--- impossible phenomenon of longitudinal wave
Flutter 如何使用在线转码工具将 JSON 转为 Model
Several schemes of traffic exposure in kubernetes cluster
DAO 中常见的投票治理方式
Resolving the conflict problem of the flutter Library
Minimum spanning tree based on Kruskal
Elegant custom ThreadPoolExecutor thread pool
985测试工程师被吊打,学历和经验到底谁更重要?