在我的代码中,我必须删除一个类,以获取其完整高度。这是在requestAnimationFrame
中完成的,但是先删除该类然后再查询scrollHeight
,将强制重排。我是否只需要在scrollHeight
中查询setTimeout
?
requestAnimationFrame(() => {
poo.style.overflow = 'visible';
poo.scrollHeight;
// Do something with it
poo.style.overflow = 'auto';
});
进入...?
requestAnimationFrame(() => {
poo.style.overflow = 'visible';
setTimeout(() => {
poo.scrollHeight;
// Do something with it
poo.style.overflow = 'auto';
}, 0);
});