gpt4 book ai didi

reactjs - Nuka-旋转木马自定义箭头按钮

转载 作者:行者123 更新时间:2023-12-03 13:42:47 25 4
gpt4 key购买 nike

我是 Nuka-carousel React 的新手。我正在尝试添加上一个-下一个箭头按钮,而不仅仅是“上一个”和“下一个”书面按钮。我找到了编写装饰器函数的各种解决方案。我已经尝试过,但没有找到我想要的输出。这是我的代码:

import Carousel from 'nuka-carousel';
import createReactClass from 'create-react-class';
var Decorators = [
{
component: createReactClass({
render() {
return (
<div>
<i className="fa fa-arrow-left" onClick={this.props.previousSlide} aria-hidden="true"></i>
</div>
)
}
}),
position: 'CenterLeft',
style: {
padding: 20
}
},
{
component: createReactClass({
render() {
return (
<div>
<i className="fa fa-arrow-right" onClick={this.props.nextSlide} aria-hidden="true"></i>
</div>
)
}
}),
position: 'CenterRight',
style: {
padding: 20
}
}
];

return(
<Carousel decortators={Decorators} slidesToShow={3} cellSpacing={50} >
{cards}
</Carousel>

);

最佳答案

我相信你需要设置render*Controls Carousel 组件的 prop(其中 * 是特定的控制位置,例如 CenterLeftCenterRight):

<Carousel
renderCenterLeftControls={({ previousSlide }) => (
<button onClick={previousSlide}>
<i className="fa fa-arrow-left" />
</button>
)}
renderCenterRightControls={({ nextSlide }) => (
<button onClick={nextSlide}>
<i className="fa fa-arrow-right"/>
</button>
)}
>
{cards}
</Carousel>

UPD:文档链接已更新

关于reactjs - Nuka-旋转木马自定义箭头按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51877665/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com