fix(mini): 首页广告词与胶囊按钮精确垂直对齐
- 用Taro.getMenuButtonBoundingClientRect()获取胶囊按钮精确top - paddingTop = menu.top,文字内容高度32px,文字中心 = menu.top + 16 = 胶囊中心 - 移除估算值statusBar+6,改为精确API获取 - 移除不再使用的getTopInset导入
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { View, Text, Button, ScrollView } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { useTabIndex } from '@/utils/tab';
|
||||
import { getTopInset } from '@/components/TopInset';
|
||||
import {
|
||||
MK_HERO, MK_TRUST, MK_PRODUCTS,
|
||||
MK_CORE, MK_SIGNUP
|
||||
@@ -11,8 +10,9 @@ import './index.scss';
|
||||
/* ---------- 首页宣传落地页 ---------- */
|
||||
export default function Index() {
|
||||
useTabIndex(2);
|
||||
const { statusBar } = getTopInset();
|
||||
const navPad = statusBar + 6; // 与右上角胶囊按钮top对齐
|
||||
// 与右上角胶囊按钮垂直中心对齐
|
||||
const menu = Taro.getMenuButtonBoundingClientRect ? Taro.getMenuButtonBoundingClientRect() : null;
|
||||
const navPad = menu ? menu.top : 50; // 胶囊top即文字paddingTop,保证中心对齐
|
||||
|
||||
const goTab = (url) => () => {
|
||||
if (/^\/pages-(extra|op)\//.test(url)) Taro.navigateTo({ url });
|
||||
|
||||
Reference in New Issue
Block a user