我的小项目有问题,我没有在显示屏上显示图像
cardData.js
async fetchData(){
await axios.get(`${this.urlApi}${this.props.url}${this.apiKey}`).then(d=>this.setState({data:d.data}))
}
componentDidMount() {
this.fetchData();
}
render() {
const data=this.state.data.results;
if(data)
return (
<div>
<h1>{this.props.title}</h1>
<div >
<Carousel slidesToShow={5} dragging={true} slidesToScroll={3} cellSpacing={5}>
{data.map(d=><Card key={d.id} title={d.title} img={d.poster_path} data={d}/>)}
</Carousel>
</div>
</div>
);
return<div className="loader" />
}
}
获取完整源代码:github repo