1 回答
![?](http://img1.sycdn.imooc.com/533e4ce900010ae802000200-100-100.jpg)
TA贡献1887条经验 获得超5个赞
正因为如此,
return ReactDOM.render( ... )
你不能从你的组件返回它。相反,您需要将最顶层的组件 (App.js) 渲染到 dom。阅读更多关于ReactDOM 这里
import ReactDOM from "react-dom"; //Import here
class App extends Component {
render() {
return (
<div className="App">
<CriaCarousel />
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('root')) //This will render on actual DOM
你的子组件应该是,
class CriaCarousel extends Component {
render() {
return (
<Carousel autoplay="true">
//<CarouselStyle> //I am not sure what is this doing, but I think you don't need it
<div>
<h3>1</h3>
</div>
<div>
<h3>2</h3>
</div>
<div>
<h3>3</h3>
</div>
<div>
<h3>4</h3>
</div>
// </CarouselStyle>
</Carousel>
);
}
}
而这CSS将是这个,
.ant-carousel .slick-slide {
text-align: center;
height: 160px;
line-height: 160px;
background: #364d79;
overflow: hidden;
}
.ant-carousel .slick-slide h3 {
color: #fff;
}
添加回答
举报