Reactjs ReactQuill:验证空输入值(显示html标记)

Reactjs ReactQuill:验证空输入值(显示html标记),reactjs,Reactjs,我在验证反应管方面有问题 场景:当我删除ReactQuill Textarea中的输入时,最后一个值将是 <p><br></p> 我的状况: if(datas.textValue.length === 0 || datas.textValue.value == '<p><br></p>') { return 'false'; } else { return 'true'; } if(datas

我在验证反应管方面有问题

场景:当我删除ReactQuill Textarea中的输入时,最后一个值将是

<p><br></p>
我的状况:

 if(datas.textValue.length === 0 || datas.textValue.value == '<p><br></p>')
 {
    return 'false';
 }
 else
 {
    return 'true';
 }
if(datas.textValue.length==0 | | datas.textValue.value=='

) { 返回“false”; } 其他的 { 返回“true”; }
React Quill使用HTML标记进行标记。要按用户检查输入文本的长度,我们可以使用下面的正则表达式从
datas.textValue
中过滤出html标记,并修剪空白(若存在)

if(datas.textValue.replace(/<(.|\n)*?>/g, '').trim().length === 0) {
    //textarea is still empty
}
if(datas.textValue.replace(//g',).trim().length==0){
//textarea仍然是空的
}

使用datas.textValue.length==1条件
if(datas.textValue.replace(/<(.|\n)*?>/g, '').trim().length === 0) {
    //textarea is still empty
}