问题描述
我想在 react js 中使用 owl carousel 但我有一个问题:
当我想从服务器获取类别时,owl carousel 不起作用, 如果初始类别在 useState 钩子(硬编码)中,则轮播可以工作,但是在 setState 之后它不起作用,抱歉我的英语, 请帮帮我
export default function Index() {
const [categories,setCategories] = useState([]);
useEffect(() => {
getCategories().then(response => {
setCategories(DataResponse(response));
}).catch(error => error);
},[]);
return (
<section className="slider-section dt-sl mb-5">
<div className="row">
<div className="col-12">
<div className="category-section-slider dt-sl">
<div className="category-slider carousel-lg owl-carousel owl-theme">
{categories.map(category => <Item key={category.id} {...category}/>)}
</div>
</div>
</div>
</div>
</section>
);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)