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