瀏覽代碼

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

- 仅在微信环境下调用Taro.getMenuButtonBoundingClientRect()获取菜单按钮信息
- 非微信环境下将menuButtonInfo设为undefined,避免运行时错误
yourname 4 月之前
父節點
當前提交
c2508422de
共有 1 個文件被更改,包括 1 次插入1 次删除
  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