import React, { useMemo } from 'react'; import Wrap from '../wrap/Wrap'; import { Upload } from 'antd'; import '../g.scss'; function ClickButtonUpload(props: IButtonAdd) { let timer = null; const { title = '', change, wrapStyle = { padding: '6px 20px 6px 20px' }, type, labelIcon = <>, style, labelWarpStyle } = props; const Dom = useMemo(() => { return ( { change?.(info, 'changeUpload'); return false; }} beforeUpload={(info, fileList) => { //防抖 clearTimeout(timer); timer = setTimeout(() => { change?.({ file: info, fileList: fileList }, 'beforeUpload'); }, 300); return false; }} >
{labelIcon} {title}
); }, [title, type]); return Dom; } export default ClickButtonUpload; export interface IButtonAdd { title?: string | number; change?: Function; wrapStyle?: React.CSSProperties; style?: React.CSSProperties; labelWarpStyle?: React.CSSProperties; type?: string; labelIcon?: React.ReactNode; }