import React, {Component} from 'react'
|
import { Carousel } from 'antd-mobile'
|
import Mp4 from '@/assets/video/testvideo.mp4'
|
|
import './index.scss'
|
|
class CarList1 extends Component {
|
state = {
|
data: ['AiyWuByWklrrUDlFignR', 'TekJlZRVCjLFexlOCuWn', 'IJOtIlfsYdTyaDTRVrLI'],
|
imgHeight: 176,
|
}
|
componentDidMount() {
|
// simulate img loading
|
// setTimeout(() => {
|
// this.setState({
|
// data: ['AiyWuByWklrrUDlFignR', 'TekJlZRVCjLFexlOCuWn', 'IJOtIlfsYdTyaDTRVrLI'],
|
// });
|
// }, 100);
|
}
|
|
render() {
|
return (
|
<Carousel
|
autoplay={false}
|
infinite
|
// beforeChange={(from, to) => }
|
// afterChange={index => }
|
>
|
{this.state.data.map(val => (
|
<span
|
key={val}
|
// href="http://www.alipay.com"
|
style={{ display: 'inline-block', width: '100%', height: this.state.imgHeight }}
|
>
|
{val !== 'AiyWuByWklrrUDlFignR' ? <img
|
src={`https://zos.alipayobjects.com/rmsportal/${val}.png`}
|
alt=""
|
style={{ width: '100%', verticalAlign: 'top', marginBottom: '3vw' }}
|
onLoad={() => {
|
// fire window resize event to change height
|
window.dispatchEvent(new Event('resize'));
|
this.setState({ imgHeight: 'auto' });
|
}}
|
/> : null}
|
{val === 'AiyWuByWklrrUDlFignR' ?
|
<video src={Mp4} controls="controls" style={{ width: '100%', height: 'auto', verticalAlign: 'top' }}>
|
your browser does not support the video tag
|
</video> : null
|
}
|
</span>
|
))}
|
</Carousel>
|
)
|
}
|
}
|
|
export default CarList1
|