我正在使用
是否可以自定義點形狀指標?
uj5u.com熱心網友回復:
是的,您可以使用 JSX 傳遞renderIndicator道具作為Carousel組件的函式來自定義點。您可以查看此沙箱以獲取此用法的實時作業示例。
<Carousel
autoPlay
infiniteLoop
showArrows={false}
renderIndicator={(onClickHandler, isSelected, index, label) => {
const defStyle = { marginLeft: 20, color: "white", cursor: "pointer" };
const style = isSelected
? { ...defStyle, color: "red" }
: { ...defStyle };
return (
<span
style={style}
onClick={onClickHandler}
onKeyDown={onClickHandler}
value={index}
key={index}
role="button"
tabIndex={0}
aria-label={`${label} ${index 1}`}
>
{"cust " index}
</span>
);
}}
>
<div>
<img src={"1.jpeg"} />
</div>
<div>
<img src={"2.jpeg"} />
</div>
<div>
<img src={"3.jpeg"} />
</div>
</Carousel>
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/342376.html
