vue配合elementui进行表单校验的两种方式

vue的表单校验是用的async-validator插件,具体可以去github查看。传送门

confirmdia () {
      this.$refs[fromname].validate(v => {
        if (v) {
          console.log(v)
          this.addDialog = false
          this.$message({
            type: 'success',
            message: '添加成功'
          })
        } else {
          return console.log('校验失败')
        }
      })
    }
 async addConfirmdia () {
      try {
        await this.$refs[fromname].validate()
        this.addValueDialog = false
        this.$message({
          type: 'success',
          message: '添加成功'
        })
      } catch (e) {
        console.log(e)
      }
    },
Last modification:November 13th, 2019 at 09:32 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment