当前位置:网站首页>微信小程序获取某个元素的信息(高、宽等),并将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边栏推荐
- Where can I check the foreign literature of economics?
- Chapter 3 of getting started with MySQL: database creation and operation
- 可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场
- Free we media essential tools sharing
- Pageoffice - bug modification journey
- Seckill system design
- Form form instantiation
- Sysdig analysis container system call
- [target detection] r-cnn, fast r-cnn, fast r-cnn learning
- TypeError: Cannot read properties of undefined (reading ***)
猜你喜欢

Pytorch里面多任务Loss是加起来还是分别backward?

MySQL 23道经典面试吊打面试官

Interface difference test - diffy tool

Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open

maya渔屋建模

Feature Engineering: summary of common feature transformation methods

Seckill system design
![[shutter] Introduction to the official example of shutter Gallery (learning example | email application | retail application | wealth management application | travel application | news application | a](/img/f2/f3b8899aa774dd32006c5928d370f1.gif)
[shutter] Introduction to the official example of shutter Gallery (learning example | email application | retail application | wealth management application | travel application | news application | a

Many to one, one to many processing
![[shutter] open the third-party shutter project](/img/1a/e35d0180612d7e79b55e7818193740.jpg)
[shutter] open the third-party shutter project
随机推荐
带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
Go自定义排序
sysdig分析容器系统调用
Where can I find the English literature of the thesis (except HowNet)?
NC50965 Largest Rectangle in a Histogram
NC24325 [USACO 2012 Mar S]Flowerpot
Thinkadmin V6 arbitrary file read vulnerability (cve-2020-25540)
Should you study kubernetes?
[shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
Missing number
Unique line of "Gelu"
[shutter] open the third-party shutter project
Form form instantiation
maya渔屋建模
NC50965 Largest Rectangle in a Histogram
[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)
helm 基础学习
Confluence的PDF导出中文文档异常显示问题解决
Markdown使用教程
Angled detection frame | calibrated depth feature for target detection (with implementation source code)