当前位置:网站首页>uniapp动态设置占位区高度(配合createSelectorQuery方法)
uniapp动态设置占位区高度(配合createSelectorQuery方法)
2022-07-21 02:29:00 【Acardia_Liu】
需求:
top-box区域为fixed布局,固定的。此时需要一个配套的占位区域,来占住top-box的位置,以防止内容区域挤压。
//view
<view class="top-box">
</view>
<!-- top-box占位 -->
<view :style="setHeight()">
</view>
//data
topHeight : 0,
//methods
// 动态设置占位区高度
setHeight() {
this.$nextTick(() => {
uni.createSelectorQuery().select('.top-box').boundingClientRect().exec((res) => {
//异步方法,无法return出去,也无法将变量传至外部,故另起一个全局变量
this.topHeight = res[0].height
})
})
return `height:${
this.topHeight}px`
}
边栏推荐
- Interface idempotency
- Part I - Fundamentals of C language_ 8. Memory management
- dp---背包问题
- Golang collection: custom types and method sets
- 一种非极大值抑制(non_max_suppression, nms)的代码实现方式
- DP --- knapsack problem
- [translation] improve stability and reliability with kubernetes + helm + flux!
- Security video monitoring platform easycvr database fields cannot be updated, how to optimize?
- Which programming language is recommended for beginners?
- Day009循环结构(练习)
猜你喜欢
OSPF基础
ESB結合UMC雲平臺開發說明
Description du développement de l'ESB en combinaison avec la plateforme UMC Cloud
After leaving a foreign company, I know what respect and compliance are
Zero basic learning canoe panel (1) -- new panel
Is it fast to render C4d with cloud?
工业4.0数字孪生下的应用案例
qt开发技巧与三个问题点
求解单源最短路径的手工实现
Digital twin community management system, construction of nine application scenarios
随机推荐
手工遍历二叉树的技巧
Visual solution of digital twin landing high-speed railway bridge
Security video monitoring platform easycvr database fields cannot be updated, how to optimize?
Introduction to C language --- operators
bryntum gantt 5.0.6
面试 02
Custom paging label
Detailed understanding of mvcc of MySQL (version 2022)
通用分页(分页代码的封装)
QT4、5、6各版本之间的特点和选择
Digital twin technology offshore wind farm solution
C language practice topic + answer: 26-30
C language practice topic + answer: 21-25
工业4.0数字孪生下的应用案例
[translation] technical writing of developers
Involution: Inverting the Inherence of Convolution for Visual Recognition(CVPR2021)
这还是我最熟悉的package.json吗?
excel转json (树状结构)
众昂矿业:萤石行业发展四大趋势
深度优先与广度优先的思想