您现在的位置是:首页 > 诗句大全

el-form组件如何清除校验提示(前端技能提升)

作者:焦糖时间:2024-04-28 13:01:37分类:诗句大全

简介  文章浏览阅读2.5k次,点赞2次,收藏2次。el-form组件如何清除校验提示_el-form清除表单校验

点击全文阅读

错误效果

错误描述 

在切换radio切换的时候校验提示提示出来了,本身不应该出来但是如何取消呢?因为在切换时候我们置空但是并没有取消校验,所以从通过到拒绝置空时候肯定会出现提示语,那么我们把提示校验的方法去掉就行了。

 错误代码

reviewStateChange(val) {      if (val === '2') {        this.ruleForm.remark = ''      }      if (val === '3') {        this.ruleForm.remark = ''      }    }

正确代码 

reviewStateChange(val) {      if (val === '2') {        this.ruleForm.remark = ''      }      if (val === '3') {        this.ruleForm.remark = ''        // this.$nextTick(() => {        //   this.$refs.ruleForm.resetFields()        // })        this.$nextTick(() => {          this.$refs.ruleForm.clearValidate() // 只清除清除验证        })      }    }

 

总结方法

①清除表单内容和清除表单验证消息

 

this.$nextTick(()=>{        this.$refs.form.resetFields();      })

 

②只清除表单验证消息、不清楚表单内容 

this.$nextTick(()=>{        this.$refs['form'].clearValidate() // 只清除清除验证      })

 正确样式

场景延申 

我们在页面切换的时候使用同一个Form组件,我们就需要把校验的结果给去掉,虽然不影响功能,但是页面显示给人感觉不太好。

 

点击全文阅读

郑重声明:

本站所有活动均为互联网所得,如有侵权请联系本站删除处理

我来说两句

fetch1("select plface from {$dbtbpre}enewspl_set limit 1"); $facer=explode("||",$r[plface]); $count=count($facer); $plface=''; $plfacereply=''; for($i=1;$i<$count-1;$i++) { $face=explode("##",$facer[$i]); $img = $public_r[newsurl].'e/data/face/'.$face[1]; $plface.='
  • '; $plfacereply.='
  • '; } $userpiclink = ''; $username = getcvar('mlusername'); $userid=getcvar('mluserid'); $rnd = getcvar('mlrnd'); if($username&&$userid&&$rnd){ $user_r = sys_ShowMemberInfo($userid,'ui.userpic'); $userpic=$user_r[userpic]?$user_r[userpic]:$public_r[newsurl].'e/extend/lgyPl/assets/nouserpic.gif'; $userpiclink = ''; $userlink=''.$username.''; } ?>
    请先说点什么
    热门评论
    0人参与,0条评论
    正在载入评论列表...