mirror of
https://github.com/MrXujiang/h5-Dooring.git
synced 2026-01-08 04:48:11 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import React, { memo, PropsWithChildren } from 'react';
|
|
import { Carousel } from 'zarm';
|
|
import styles from './index.less';
|
|
import { CarouselConfigType } from '../DynamicEngine/schema';
|
|
|
|
interface CarouselTypes extends CarouselConfigType {
|
|
isTpl: boolean;
|
|
}
|
|
|
|
const XCarousel = memo((props: PropsWithChildren<CarouselTypes>) => {
|
|
const { direction, swipeable, autoPlay, isTpl, imgList, tplImg } = props;
|
|
const contentRender = () => {
|
|
return imgList.map((item, i) => {
|
|
return (
|
|
<div className={styles.carousel__item__pic} key={+i}>
|
|
<img src={item.imgUrl[0].url} alt="" />
|
|
</div>
|
|
);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<div style={{ width: '100%', overflow: 'hidden' }}>
|
|
{isTpl ? (
|
|
<div className={styles.carousel__item__pic}>
|
|
<img src={tplImg} alt="" />
|
|
</div>
|
|
) : (
|
|
<Carousel
|
|
onChange={index => {
|
|
// console.log(`onChange: ${index}`);
|
|
}}
|
|
direction={direction}
|
|
swipeable={swipeable}
|
|
autoPlay={autoPlay}
|
|
loop
|
|
>
|
|
{contentRender()}
|
|
</Carousel>
|
|
)}
|
|
</div>
|
|
);
|
|
});
|
|
|
|
export default XCarousel;
|