当前位置:网站首页>微信小程序获取某个元素的信息(高、宽等),并将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边栏推荐
- setInterval定时器在ie不生效原因之一:回调的是箭头函数
- Thinkadmin V6 arbitrary file read vulnerability (cve-2020-25540)
- 程序分析与优化 - 9 附录 XLA的缓冲区指派
- The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
- Multi process programming (III): message queue
- FRP reverse proxy +msf get shell
- Chapter 4 of getting started with MySQL: data types stored in data tables
- Leetcode skimming - game 280
- S12. Verify multi host SSH mutual access script based on key
- Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity
猜你喜欢

Markdown tutorial
![[shutter] shutter open source project reference](/img/3f/b1d4edd8f8e8fd8e6b39548448270d.jpg)
[shutter] shutter open source project reference
![Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation](/img/4a/ab732c41ea8a939fa0983fec475622.png)
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation

Cmake basic use

35 pages dangerous chemicals safety management platform solution 2022 Edition
![洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举](/img/a3/55bb71d39801ceeee421a0c8ded333.png)
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举

Which websites can I search for references when writing a thesis?

Install docker and use docker to install MySQL

有哪些比较推荐的论文翻译软件?

pageoffice-之bug修改之旅
随机推荐
带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
Feature Engineering: summary of common feature transformation methods
MFC gets the current time
Markdown使用教程
MySQL advanced learning notes (4)
UART、RS232、RS485、I2C和SPI的介绍
Multiprocess programming (4): shared memory
Nc20806 District interval
Where can I check the foreign literature of economics?
Seckill system design
英文论文有具体的格式吗?
67 page overall planning and construction plan for a new smart city (download attached)
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
Maya fishing house modeling
Angled detection frame | calibrated depth feature for target detection (with implementation source code)
S12. Verify multi host SSH mutual access script based on key
Nc50528 sliding window
有哪些比较推荐的论文翻译软件?
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表
Realization of mask recognition based on OpenCV