当前位置:网站首页>Wechat applet obtains the information of an element (height, width, etc.) and converts PX to rpx.
Wechat applet obtains the information of an element (height, width, etc.) and converts PX to rpx.
2022-07-03 00:28:00 【Pumpkin_ xiaoXuan】
<!-- Customize the bottom navigation bar Here we have to define class Below heel .select() Agreement -->
<tab-bar class="tabbar" :currentTabBar="0" :themeColors="themeColors"></tab-bar>
// Get the height of the bottom navigation bar
getTabBarHeight() {
let query = uni.createSelectorQuery().in(this);
query
.select(".tabbar") // there .tabbar Is the class name of the element
.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);
})
},
// You need to wait while calling dom Call after rendering
this.$nextTick(() => {
this.getFixedItemInfo()
this.getTabBarHeight()
})
// Here is to convert the obtained height into rpx, Because in different models px turn rpx It's inconsistent
let system = uni.getSystemInfoSync();
let tabBarHeightPx = res[0].height;
let rpx = system.windowWidth / 750;
this.tabBarHeightRpx = tabBarHeightPx / rpx
边栏推荐
- Additional: token; (don't read until you finish writing...)
- Graduation summary
- Multiprocess programming (V): semaphores
- Define MySQL function to realize multi module call
- Missing number
- Is there a specific format for English papers?
- Introduction of UART, RS232, RS485, I2C and SPI
- JS interviewer wants to know how much you understand call, apply, bind no regrets series
- 写论文可以去哪些网站搜索参考文献?
- Install docker and use docker to install MySQL
猜你喜欢
setInterval定时器在ie不生效原因之一:回调的是箭头函数
Chapter 3 of getting started with MySQL: database creation and operation
Maya fishing house modeling
redis21道经典面试题,极限拉扯面试官
Where can I find the English literature of the thesis (except HowNet)?
[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举
Bloom filter
有哪些比较推荐的论文翻译软件?
哪些软件可以整篇翻译英文论文?
随机推荐
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
Nc20806 District interval
Is there a specific format for English papers?
【Pulsar文档】概念和架构/Concepts and Architecture
JVM foundation review
Shell脚本基本使用
NC20806 区区区间间间
Multiprocess programming (I): basic concepts
Implement the foreach method of array
秒杀系统设计
NC24325 [USACO 2012 Mar S]Flowerpot
How to write the design scheme of the thesis?
Program analysis and Optimization - 9 appendix XLA buffer assignment
[MCU project training] eight way answering machine
Basic 10 of C language: array and pointer
NC50965 Largest Rectangle in a Histogram
Digital collection trading website domestic digital collection trading platform
Xcode real machine debugging
Introduction of UART, RS232, RS485, I2C and SPI
Go自定义排序