feat: 本次提交更新内容如下

layout兼容问题
This commit is contained in:
笔记本里的永平
2025-07-25 16:15:52 +08:00
parent b3a1137d8e
commit a243e66746
5 changed files with 67 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import React from "react";
import React, { useEffect } from "react";
import { SpinLoading } from "antd-mobile";
import styles from "./layout.module.scss";
@@ -15,8 +15,24 @@ const Layout: React.FC<LayoutProps> = ({
footer,
loading = false,
}) => {
// 移动端100vh兼容
useEffect(() => {
const setRealHeight = () => {
document.documentElement.style.setProperty(
"--real-vh",
`${window.innerHeight * 0.01}px`
);
};
setRealHeight();
window.addEventListener("resize", setRealHeight);
return () => window.removeEventListener("resize", setRealHeight);
}, []);
return (
<div className={styles.container}>
<div
className={styles.container}
style={{ height: "calc(var(--real-vh, 1vh) * 100)" }}
>
{header && <header>{header}</header>}
<main>
{loading ? (