Ver Fonte

🐛 fix(navbar): 修复非微信环境下获取菜单按钮信息的错误

- 仅在微信环境下调用Taro.getMenuButtonBoundingClientRect()获取菜单按钮信息
- 非微信环境下将menuButtonInfo设为undefined,避免运行时错误
yourname há 4 meses atrás
pai
commit
c2508422de
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      mini/src/components/ui/navbar.tsx

+ 1 - 1
mini/src/components/ui/navbar.tsx

@@ -24,7 +24,7 @@ export interface NavbarProps {
 }
 
 const systemInfo = Taro.getSystemInfoSync()
-const menuButtonInfo = Taro.getMenuButtonBoundingClientRect()
+const menuButtonInfo = isWeapp() ? Taro.getMenuButtonBoundingClientRect() : undefined
 
 // 计算导航栏高度
 const NAVBAR_HEIGHT = 44