diff --git a/components/Signature/index.d.ts b/components/Signature/index.d.ts index 66dbff9..cae62af 100644 --- a/components/Signature/index.d.ts +++ b/components/Signature/index.d.ts @@ -16,6 +16,8 @@ export interface SignatureProps { width?: number; /** 签字区域高度,默认为 300 */ height?: number; + /** 回显的签字图片 */ + url?: string; } /** diff --git a/components/Signature/index.js b/components/Signature/index.js index 4d2e7e2..1270226 100644 --- a/components/Signature/index.js +++ b/components/Signature/index.js @@ -1,6 +1,6 @@ import { Button, Image, message, Modal } from "antd"; import dayjs from "dayjs"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import SignatureCanvas from "react-signature-canvas"; import { base642File } from "../../utils"; @@ -12,12 +12,16 @@ function Signature(props) { onConfirm, width = 752, height = 300, + url = "", ...restProps } = props; const [signatureModalOpen, setSignatureModalOpen] = useState(false); const signatureCanvas = useRef(null); const [base64, setBase64] = useState(""); + useEffect(() => { + setBase64(url); + }, [url]); const onOk = () => { if (signatureCanvas.current.isEmpty()) { @@ -49,7 +53,7 @@ function Signature(props) { {base64 && (
- +
)}