Closed Dreamcreative closed 1 year ago
const Com = () => { useLayoutEffect(() => { const rt = document.querySelector(".com")?.getBoundingClientRect(); console.log(rt); }, []); return <div className="com">获取元素高度</div>; }; const AliveRecord = props => ( <KeepAlive> <Com {...props} /> </KeepAlive> );
这个是不是 .com 元素没获取到
.com
参考 https://github.com/CJY0208/react-activation/blob/master/README_CN.md#breaking-change-%E7%94%B1%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86%E5%BC%95%E5%8F%91%E7%9A%84%E9%A2%9D%E5%A4%96%E9%97%AE%E9%A2%98 此处第 1 点