zzc-design-mobile icon indicating copy to clipboard operation
zzc-design-mobile copied to clipboard

单页面,输入框设为失焦校验,聚焦状态跳转会有问题

Open m2rbl3 opened this issue 4 years ago • 0 comments

react-router v4构建的单页面网页,如果在输入框聚焦状态下点击跳转,会因为失焦执行FormItemvalidationData方法,但因为是延迟100ms才执行,此时组件已经销毁,导致报错。

    validationData(id: string) {
        if (this.validationTime) {
            clearTimeout(this.validationTime);
            this.validationTime = null;
        }
        this.validationTime = setTimeout(() => {
            const { formContext } = this.props;
            formContext.validation(id, null);
        }, 100);
    }

m2rbl3 avatar Mar 26 '20 10:03 m2rbl3