Skip to content

Commit 72ba746

Browse files
committed
wip(x): 支付宝小程序兼容 statusBarHeight
1 parent 5a8f613 commit 72ba746

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/uni-mp-vue/src/plugin.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ import { UNI_STATUS_BAR_HEIGHT } from '@dcloudio/uni-shared'
66
// #endif
77
import { pruneComponentPropsCache } from './helpers/renderProps'
88

9+
// #if _X_
10+
function getStatusBarHeight() {
11+
if (typeof wx !== 'undefined') {
12+
return wx.getWindowInfo().statusBarHeight
13+
// @ts-expect-error
14+
} else if (typeof my !== 'undefined') {
15+
// @ts-expect-error
16+
return my.getWindowInfo().statusBarHeight
17+
}
18+
}
19+
// #endif
20+
921
export default {
1022
install(app: App) {
1123
initApp(app)
@@ -14,8 +26,7 @@ export default {
1426
pruneComponentPropsCache
1527
// #if _X_
1628
// TODO 此处不支持 __GLOBAL__,并且有些小程序(如抖音小程序)没有 getWindowInfo 方法
17-
app.config.globalProperties[UNI_STATUS_BAR_HEIGHT] =
18-
wx.getWindowInfo().statusBarHeight
29+
app.config.globalProperties[UNI_STATUS_BAR_HEIGHT] = getStatusBarHeight()
1930
// #endif
2031
const oldMount = app.mount
2132
app.mount = function mount(rootContainer: any) {

0 commit comments

Comments
 (0)