// 获取设备信息 app.vue => onLaunch()中调佣
getSystemInfo() {
let statusBarHeight = '';
let totalHeightPX = '';
let totalHeightRPX = '';
let windowWidth = '';
uni.getSystemInfo({
success: res => {
windowWidth = res.windowWidth;
// 状态栏高度
statusBarHeight = res.statusBarHeight;
// 状态栏高度 + 导航栏高度(单位px),,, ,,, 固定44px(导航栏)
totalHeightPX = statusBarHeight + 44;
//将高度乘以换算后的该设备的rpx与px的比例
totalHeightRPX = totalHeightPX * (750 / windowWidth);
Vue.prototype.systemInfo = {
statusBarHeight,
totalHeightPX, // 使用这个高度做吸附
totalHeightRPX,
windowWidth
};
}
});
},
uni-app 小程序端计算胶囊按钮高度 做吸附置顶效果
最新推荐文章于 2024-06-18 10:28:11 发布