From 6be6213fb909e1f2ea8a305e92a9e931c5e9935c Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Wed, 19 May 2021 21:58:06 +0800 Subject: [PATCH] =?UTF-8?q?uuid=20=E6=9C=89=E5=80=BC=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE,=20=E6=B2=A1=E5=80=BC=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Form/UUID.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/renderers/Form/UUID.tsx b/src/renderers/Form/UUID.tsx index a1a88cd51..e4e7a6267 100644 --- a/src/renderers/Form/UUID.tsx +++ b/src/renderers/Form/UUID.tsx @@ -20,6 +20,19 @@ export default class UUIDControl extends React.Component< > { constructor(props: FormControlProps) { super(props); + if (!props.value) { + this.setValue(); + } + } + + componentDidUpdate(props: FormControlProps) { + if (!props.value) { + this.setValue(); + } + } + + setValue() { + const props = this.props; let uuid = uuidv4(); if (props.length) { uuid = uuid.substring(0, props.length);