zy-react-library/components/PreviewImg/index.js

33 lines
746 B
JavaScript
Raw Normal View History

2025-10-22 14:43:42 +08:00
import { Image } from "antd";
import { getFileUrl } from "../../utils/index";
/**
* 在查看页面中图片预览组件
*/
2025-10-22 14:43:42 +08:00
const PreviewImg = (props) => {
const { files = [], fileUrlKey = "filePath" } = props;
2025-10-22 14:43:42 +08:00
const fileUrl = getFileUrl();
return (
<Image.PreviewGroup>
{
2025-12-24 15:45:07 +08:00
files.filter(Boolean).map(item => (
2025-10-22 14:43:42 +08:00
<Image
key={item[fileUrlKey] || item}
src={item[fileUrlKey] ? fileUrl + item[fileUrlKey] : fileUrl + item}
2025-12-17 10:18:51 +08:00
wrapperStyle={{ marginRight: 10, marginBottom: 10 }}
2025-10-22 14:43:42 +08:00
width={100}
height={100}
alt=""
/>
))
}
</Image.PreviewGroup>
);
};
2025-12-24 15:45:07 +08:00
PreviewImg.displayName = "PreviewImg";
2025-10-22 14:43:42 +08:00
export default PreviewImg;