Reactjs React组件中的引导Carousal:不工作
我正在使用“CreateReact应用程序”开发电子web应用程序。我正在使用上下文API将数据获取到这个名为Carousal.js的组件 从React的引导程序中,但我的图像没有显示在carousal中。我尝试通过放置 我不明白我做错了什么?**img和img2来自上下文API 我的代码如下:Reactjs React组件中的引导Carousal:不工作,reactjs,bootstrap-4,bootstrap-carousel,Reactjs,Bootstrap 4,Bootstrap Carousel,我正在使用“CreateReact应用程序”开发电子web应用程序。我正在使用上下文API将数据获取到这个名为Carousal.js的组件 从React的引导程序中,但我的图像没有显示在carousal中。我尝试通过放置 我不明白我做错了什么?**img和img2来自上下文API 我的代码如下: export default class Details extends Component { render() { return ( <
export default class Details extends Component {
render() {
return (
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
</ol>
<div className="carousel-inner">
<div className="carousel-item">
<img className="d-block w-100" src={img} alt="Second slide"/>
</div>
<div className="carousel-item">
<img className="d-block w-100" src={img2} alt="Third slide"/>
</div>
</div>
<a className="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span className="carousel-control-prev-icon" aria-hidden="true"></span>
<span className="sr-only">Previous</span>
</a>
<a className="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span className="carousel-control-next-icon" aria-hidden="true"></span>
<span className="sr-only">Next</span>
</a>
</div>
)
}}
导出默认类详细信息扩展组件{
render(){
返回(
)
}}
此代码是否在渲染部分中?如果您可以共享其他代码,也可以将img和img2记录到console.log中,以检查valsI did console.log及其正确呈现。代码在render函数中。我已经编辑了上面的代码。请看一看。如果你硬编码,你的图像能工作吗?它能!如果我硬编码,它会工作。你是如何从上下文中获取img数据的?是这样的:让img=this.context;