/* * @Author: your name * @Date: 2021-12-17 10:12:52 * @Description: * @FilePath: \zl-business\src\components\Unit\colorPick\index.tsx */ import React, { useMemo } from 'react'; import Wrap from '../wrap/Wrap'; import { Upload } from 'antd'; import '../g.scss'; function UploadWrap(props: IUploadWrap) { const { value, change, imgText, wrapStyle = { padding: '6px 20px 6px 20px' } } = props; const rendertext = (imgText: any): any => { if (typeof imgText === 'string') { return {imgText}; } else { return ( {Array.isArray(imgText) && imgText?.length > 0 && imgText.map((item, index) => { return ( { e.stopPropagation(); change?.(null, item); }} > {item} ); })} ); } }; const Dom = useMemo(() => { return ( change?.([file, fileList], 'beforeUpload') } onChange={(file, fileList, event) => change?.([file, fileList, event], 'change') } >
背景图
{rendertext(imgText)}
); }, [value, imgText, wrapStyle]); return Dom; } export default UploadWrap; export interface IUploadWrap { value: string; change?: Function; imgText?: any; wrapStyle: React.CSSProperties; }