uuid 有值时不设置, 没值自动设置

This commit is contained in:
2betop 2021-05-19 21:58:06 +08:00
parent ad89f8a587
commit 6be6213fb9

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