From 3032b23beef27f11619d8837403d01aef4f93b5e Mon Sep 17 00:00:00 2001 From: yunkexin <760754045@qq.com> Date: Thu, 23 May 2024 16:39:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E5=90=AC=E9=A1=B5=E9=9D=A2=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/Home.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/routes/Home.js b/src/routes/Home.js index 5726e21..f648c2f 100644 --- a/src/routes/Home.js +++ b/src/routes/Home.js @@ -232,6 +232,7 @@ class Home extends React.Component { }, ], }; + this.resizeRef = React.createRef(); } componentDidMount() { @@ -285,6 +286,21 @@ class Home extends React.Component { componentWillUnmount() { this.timerID && clearTimeout(this.timerID); } + useEffect = () => { + // 监听的函数 + const resize = new ResizeObserver((e) => { + if (!Array.isArray(e) || !e.length) return; + for (const ent of e) { + resizeChange(ent); + } + }); + // 传入监听对象 + resize.observe(resizeRef.current); + // 及时销毁监听函数(重要!!!) + return () => { + resize.unobserve(resizeRef?.current); + }; + }; showModalSign = () => { var userId = storage("lacal").getItem("userid")?.val; //登录后有存储登录信息 var orgId = storage("lacal").getItem("webOrgId")?.val; //登录后有存储登录信息