uniapp 獲取屏幕高度

:style="'height: '+(emulator_Height+100)+'rpx;  width:750rpx;'"

data(){
  return{
      emulator_Height: 0, //屏幕高度
    }
  },
        onShow() {
            
            // 獲取屏幕高度
            let self = this;
            uni.getSystemInfo({
                success: function(res) {
                    console.log(res.screenHeight); //屏幕高度  注意這里獲得的高度寬度都是px 需要轉換rpx
                    console.log(res.windowWidth); //可使用窗口寬度
                    console.log(res.windowHeight); //可使用窗口高度
                    console.log(res.screenWidth); //屏幕寬度
                    self.emulator_Height = (res.screenHeight * (750 / res.windowWidth)) //將px 轉換rpx
                    console.log("rpx*********", self.emulator_Height)
                }
            });
        }

uni鍵盤收起

uni.hideKeyboard()
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容