我添加react-slick
到我的项目中以显示carousel
. 我想使用位于滑块内容顶部的自定义下一个和上一个按钮来控制我的滑块。所以我遵循了自定义箭头文档,但我不想在光滑的内容中显示我的按钮,我想将控件提供给滑块内容上方的按钮。如何做到这一点?我从我创建的组件中包含了我的代码。
import React from 'react';
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
import Slider from "react-slick";
import { styled } from '@material-ui/styles';
import Button from '@material-ui/core/Button';
function SampleNextArrow(props) {
const { onClick } = props;
return (
<React.Fragment>
<Button
onClick={onClick} className="slickRight">
Next
</Button>
</React.Fragment>
);
}
function SamplePrevArrow(props) {
const { onClick } = props;
return (
<React.Fragment>
<Button
onClick={onClick} className="slickLeft">
Prev
</Button>
</React.Fragment>
);
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {}
}
render() {
var settings = {
infinite: true,
speed: 500,
slidesToShow: 4,
slidesToScroll: 1,
nextArrow: <SampleNextArrow />,
prevArrow: <SamplePrevArrow />,
};
return (
<div>
{/*Want to Add Control to this Buttons*/
<Button>Prev</Button>
<Button>Next</Button>
<div className="container">
<Slider {...settings}>
<div>
<h3>1</h3>
</div>
<div>
<h3>2</h3>
</div>
<div>
<h3>3</h3>
</div>
</Slider>
</div>
</div>
);
}
}
export default App;