我是React的新手,尝试使用react awsome滑块可正常工作,但我想在滑块图像上添加按钮和文字,但不知道该怎么做。
这是我的滑块组件
import React, { Component } from 'react'
import slider1 from '../images/slider/1.jpg'
import AwesomeSlider from 'react-awesome-slider'
import withAutoplay from 'react-awesome-slider/dist/autoplay'
import 'react-awesome-slider/dist/styles.css'
const AutoplaySlider = withAutoplay(AwesomeSlider)
class Slider extends Component {
render () {
return (
<div className='slider-area'>
<AutoplaySlider
play
cancelOnInteraction={false} // should stop playing on user interaction
interval={6000}
>
<div data-src={slider1} />
<div data-src={slider1} />
<div data-src={slider1} />
</AutoplaySlider>
</div>
)
}
}
如果有人可以提供帮助,我将非常感谢。谢谢
将organicArrows
设置为false并提供buttonContentRight
和buttonContentLeft
。它将起作用。
<AwesomeSlider
organicArrows={false}
buttonContentRight={<p style={{ color: "black" }}>Right</p>}
buttonContentLeft={<p style={{ color: "black" }}>Right</p>}
play
cancelOnInteraction={false} // should stop playing on user interaction
interval={6000}
>
<div data-src={"https://randomuser.me/api/portraits/women/43.jpg"} />
<div data-src={"https://randomuser.me/api/portraits/women/44.jpg"} />
</AwesomeSlider>