zoukankan      html  css  js  c++  java
  • 使用elementui 的validateField,resetFields,clearValidate的使用

    1  validateField 对部分表单字段进行校验的方法,Function(props: array | string, callback: Function(errorMessage: string))

    eg:this.$refs.newForm.validateField('photos')
     
    2  resetFields 对整个表单进行重置,将所有字段值重置为初始值并移除校验结果
    eg:this.$refs.newForm.resetFields()
     
    3 clearValidate 移除表单项的校验结果。传入待移除的表单项的 prop 属性或者 prop 组成的数组,如不传则移除整个表单的校验结果
    eg:this.$refs.newForm.clearValidate()
            this.$refs.newForm.clearValidate('photos')

    需要注意的是:当手动将内容清空后再使用resetFields ,会被初始化为清空之前(只限于被清空的内容)如:
    newObj:{
      parsA: ‘’,
      parsB:‘’,
    }
    //因编辑需要数据回显使得newObj变为如下数据:
    newObj:{
      parsA: ‘a’,
      parsB:‘b’,
    }
    //手动重置了 newObj.parsA = ''
    //在使用this.$refs.newForm.resetFileds()
    //会使得newObj变为如下内容:
    newObj:{
      parsA: ‘a’,
      parsB:‘’,
    }
    

      

  • 相关阅读:
    POJ 3177 Redundant Paths(无向图缩点)
    POJ 1502 MPI Maelstrom
    LightOJ 1094
    POJ 1564 Sum It Up(深搜)
    C语言复习6_doWhile循环
    进阶学习
    C语言复习5_调试
    C语言复习4_while循环
    C语言复习3_条件结构
    C语言复习2_运算符
  • 原文地址:https://www.cnblogs.com/xhliang/p/14298475.html
Copyright © 2011-2022 走看看