1 回答

TA貢獻1887條經(jīng)驗 獲得超5個贊
正因為如此,
return ReactDOM.render( ... )
你不能從你的組件返回它。相反,您需要將最頂層的組件 (App.js) 渲染到 dom。閱讀更多關(guān)于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
你的子組件應(yīng)該是,
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;
}
添加回答
舉報