UNPKG

press-next

Version:

Vue3 组件库,支持 Composition API

37 lines (28 loc) 648 B
let statusBarHeight = 20; let gotMenuInfo = false; // #ifdef H5 statusBarHeight = 0; gotMenuInfo = true; // #endif export function getStatusBarHeight(): Promise<number> { return new Promise((resolve, reject) => { if (gotMenuInfo) { resolve(statusBarHeight); return; } uni.getSystemInfo({ success: (result) => { if (result.statusBarHeight) { gotMenuInfo = true; statusBarHeight = result.statusBarHeight; } resolve(statusBarHeight); }, fail: (error) => { console.warn(error); reject(error); }, }); }); } getStatusBarHeight();