瀏覽代碼

添加获取系统信息js,用于设置全局属性

htc 1 年之前
父節點
當前提交
3eac763f3a
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      utils/getSystemInfo.js

+ 18 - 0
utils/getSystemInfo.js

@@ -0,0 +1,18 @@
+export default {
+	data() {
+		return {
+			h:uni.getSystemInfoSync().windowHeight,//屏幕高度
+			mt:uni.getSystemInfoSync().statusBarHeight + 44,//自定义头部组件高度(使用自定义头部组件的上边距)
+			th:50+uni.getSystemInfoSync().safeAreaInsets.bottom//底部tabbar高度
+		}
+	},
+	onShow(){
+		uni.getSystemInfo({
+			success:res=>{
+				if(res.platform === 'android'){
+					this.th = res.screenHeight - res.windowHeight - res.statusBarHeight - 48;
+				}
+			}
+		})
+	}
+}