我在我的物品上使用了MiniMasonry,但是它們相互堆疊在一起。為什么會這樣?
請畫在下面 https://prnt.sc/N5ISAEzVMura
我已經(jīng)努力很久了。我想知道這個(gè)問題出在哪里,解決方案是什么
import { useEffect, useState, useRef } from 'react';
const containerRef = useRef();
useEffect(() => {
if (containerRef.current?.classList.contains('masonry') && feedLayoutStyle === "masonry") {
var masonayrObj = new MiniMasonry({
container: containerRef.current,
gutterX: 40,
gutterY: 40,
minify: false,
ultimateGutter: 5,
surroundingGutter: true
});
setMiniMasonry(masonayrObj);
} else {
miniMasonry?.destroy();
}
}, [feedLayoutStyle]);
<div ref={containerRef} >
<div className="Single_item">
<div className="img">
<img src={userInfo?.avatar_url} alt="" />
</div>
</div>
</div>