监听页面尺寸变化
This commit is contained in:
parent
a281990f61
commit
3032b23bee
@ -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; //登录后有存储登录信息
|
||||
|
||||
Loading…
Reference in New Issue
Block a user