解决uniapp状态栏高度和刘海屏适配问题



data(){
    return {
        statusBarHeight: 20
    }
},
onLoad(){
    let statusBarObj = this.getPhoneInfo()
    this.statusBarHeight = statusBarObj.statusBarHeight
},
computed: {
	style() {
		var statusBarHeight = this.statusBarHeight;
        return statusBarHeight;
    },
},
methods: {
//  判断是否有刘海屏
    getPhoneInfo() {
		const phoneInfo = uni.getSystemInfoSync(); // 获取手机系统信息
		let statusBarObj = {
			statusBarHeight: 20
		}
		// 设置状态栏高度(H5顶部无状态栏小程序有状态栏需要撑起高度)
		statusBarObj.statusBarHeight = phoneInfo.statusBarHeight;
		return statusBarObj;
	}
}

你可能感兴趣的:(uni-app,java,前端)