【发布时间】:2022-12-12 09:40:49
【问题描述】:
我使用反应图像滑块image slider
问题是,当我像在代码示例中那样存储图像路径时,它工作正常
const images = [
{ url: "1.jpg" },
{ url: "2.jpg" }
];
但是当我使用它时,图像滑块不起作用
const [imagePath, setImagePath] = useState([]);
const fetchData = async () => {
const images = await (await MessageService.getImagesById(location.state.message)).data; //here i get data from db
const imagesPath = images.map(i => ({url: i.url}))
setImagePath(imagesPath);
console.log(imagesPath);//[ {url: "1.jpg"}, {url: "2.jpg"}]
}
};
useEffect(() => {
fetchData();
});
【问题讨论】:
标签: javascript reactjs image-slider