preView.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from 'react';
import { Carousel, Modal } from 'antd-mobile';
import styles from './preView.less';
/**
* 图片预览函数
* @param {*} urls 图片地址数组
* @param {*} e 点击事件,用于阻止冒泡
*/
const perView = (urls, e) => {
if (e) e.stopPropagation();
Modal.alert(
'预览',
<Carousel
className={styles.spaceCarousel}
frameOverflow="visible"
cellSpacing={10}
slideWidth={0.8}
infinite
>
{urls.map(val => (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
<a
key={val}
// eslint-disable-next-line no-script-url
href="javascript:void(0);"
style={{
display: 'block',
position: 'relative',
minHeight: 200,
boxShadow: '2px 1px 1px rgba(0, 0, 0, 0.2)',
}}
>
<img
key={val}
src={val}
alt=""
style={{ width: '100%', verticalAlign: 'top' }}
/>
</a>
))}
</Carousel>,
[
{ text: '关闭' },
],
);
};
export default perView;