Merge pull request #1984 from 2betop/uuid

uuid 有值时不设置, 没值自动设置
This commit is contained in:
吴多益 2021-05-19 23:13:23 +08:00 committed by GitHub
commit e51693e053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);