当前位置:网站首页>微信小程序获取某个元素的信息(高、宽等),并将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
边栏推荐
- LeedCode1480.一维数组的动态和
- Go custom sort
- Cmake basic use
- NC50528 滑动窗口
- Chapter 3 of getting started with MySQL: database creation and operation
- 130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
- Pytorch 20 realizes corrosion expansion based on pytorch
- Interface difference test - diffy tool
- Question e: merged fruit -noip2004tgt2
- Bypass AV with golang
猜你喜欢
Multiprocess programming (I): basic concepts
setInterval定时器在ie不生效原因之一:回调的是箭头函数
监控容器运行时工具Falco
MySQL 23 classic interview hanging interviewer
Understanding and application of least square method
Confluence的PDF导出中文文档异常显示问题解决
Explain in detail the process of realizing Chinese text classification by CNN
Basic 10 of C language: array and pointer
Talk with the interviewer about the pit of MySQL sorting (including: duplicate data problem in order by limit page)
In February 2022, the ranking list of domestic databases: oceanbase regained its popularity with "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
随机推荐
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
zhvoice
Slf4j + Logback日志框架
Andorid 获取系统标题栏高度
Digital collection trading website domestic digital collection trading platform
Leetcode skimming - game 280
pod生命周期详解
Many to one, one to many processing
经济学外文文献在哪查?
Is there a specific format for English papers?
【单片机项目实训】八路抢答器
多进程编程(五):信号量
Multiprocess programming (4): shared memory
英文论文有具体的格式吗?
多进程编程(四):共享内存
Graduation summary
MySQL 23道经典面试吊打面试官
NC17059 队列Q
UART、RS232、RS485、I2C和SPI的介绍
写论文可以去哪些网站搜索参考文献?