
如上图:当当前元素的状态发生改变时,比如身份证的长度不能为null,否则在失去焦点时给添加个提示的类样式,满足要求时就移除这个类
onInputBlur:function(e){
if(e.target.value.length<1)
// alert('')
},
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
把验证结果作为 state,验证不通过的时候改变 state,在 render 里根据 state 添加合适的 className。
可以试试找个 react form 库,写起来会方便点。
可以用classnames