uniapp 获取屏幕的高度 和px转换rpx


 1 onLoad() {
 2             uni.getSystemInfo({
 3                 success: function (res) {
 4                     console.log(res.screenHeight); //屏幕高度  注意这里获得的高度宽度都是px 需要转换rpx
 5                     console.log(res.windowWidth);  //可使用窗口宽度
 6                     console.log(res.windowHeight); //可使用窗口高度
 7                     console.log(res.screenWidth); //屏幕宽度
 8                     var rpx=(res.screenHeight * (750 / res.windowWidth))  //将px 转换rpx
 9                     console.log(rpx)
10                 }
11             });
12         },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM