当前位置:网站首页>微信小程序获取某个元素的信息(高、宽等),并将px转换为rpx。
微信小程序获取某个元素的信息(高、宽等),并将px转换为rpx。
2022-07-02 23:09:00 【Pumpkin_xiaoXuan】
<!-- 自定义底部导航栏 这里得定义个class跟下方的.select()一致-->
<tab-bar class="tabbar" :currentTabBar="0" :themeColors="themeColors"></tab-bar>
// 获取底部导航栏高度
getTabBarHeight() {
let query = uni.createSelectorQuery().in(this);
query
.select(".tabbar") // 这里的.tabbar为该元素的类名
.boundingClientRect()
.exec((res) => {
let system = uni.getSystemInfoSync();
let tabBarHeightPx = res[0].height;
let rpx = system.windowWidth / 750;
this.tabBarHeightRpx = tabBarHeightPx / rpx
console.log('tabBarHeightRpx', this.tabBarHeightRpx);
})
},
// 调用时需要等dom渲染完毕再调用
this.$nextTick(() => {
this.getFixedItemInfo()
this.getTabBarHeight()
})// 这里是把拿到的高度转换为rpx,因为在不同机型下 px转rpx是不一致的
let system = uni.getSystemInfoSync();
let tabBarHeightPx = res[0].height;
let rpx = system.windowWidth / 750;
this.tabBarHeightRpx = tabBarHeightPx / rpx边栏推荐
- Markdown tutorial
- form表单实例化
- Several methods of the minimum value in the maximum value of group query
- How to write the design scheme of the thesis?
- Markdown使用教程
- 可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场
- SQL query statement parameters are written successfully
- How to specify const array in the global scope of rust- How to specify const array in global scope in Rust?
- Mutual exclusion and synchronization of threads
- Nc20806 District interval
猜你喜欢

Chapter 3 of getting started with MySQL: database creation and operation

sysdig分析容器系统调用
![[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)](/img/f7/a8eb8e40b9ea25021751d7150936ac.jpg)
[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)

How do educators find foreign language references?
![洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举](/img/a3/55bb71d39801ceeee421a0c8ded333.png)
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举

Multiprocess programming (I): basic concepts

Digital twin visualization solution digital twin visualization 3D platform

【单片机项目实训】八路抢答器

TypeError: Cannot read properties of undefined (reading ***)

Sysdig analysis container system call
随机推荐
NC50965 Largest Rectangle in a Histogram
Open Source | Wenxin Big Model Ernie Tiny Lightweight Technology, Accurate and Fast, full Open Effect
How to specify const array in the global scope of rust- How to specify const array in global scope in Rust?
Nc50528 sliding window
经济学外文文献在哪查?
带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
Where can I find foreign papers?
Where can I check the foreign literature of economics?
Mutual exclusion and synchronization of threads
大学生课堂作业2000~3000字的小论文,标准格式是什么?
Multiprocess programming (V): semaphores
[reading notes] phased summary of writing reading notes
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
Go custom sort
[Chongqing Guangdong education] audio visual language reference materials of Xinyang Normal University
Program analysis and Optimization - 9 appendix XLA buffer assignment
Graduation summary
Pytorch 20 realizes corrosion expansion based on pytorch
helm 基础学习
有哪些比较推荐的论文翻译软件?