0

I want to validate a part first, and then the user will receive the mobile phone validation code, and then validate all when the user submits it. But I can't get the wrong information from this.errors.first('field') for the first time.

<template lang="html">
  <div>
    <form data-vv-scope="s">
        <input type="text" v-validate="'required'" data-vv-name="s1">
        <input type="text" v-validate="'required'" data-vv-name="s1">
        <button @click="vali" type="button">submit</button>
        <div @click="see">see</div>
    </form>
  </div>
</template>

<script>
import { ErrorBag } from 'vee-validate';
export default {
  methods:{
    vali () {
        this.$validator.validateAll(["s1"]);
    },
    see () {
        console.log(this.errors.first("s1")) //can't get the wrong information
    }
  }
}
</script>

1 Answers1

0

When a field has a scope, you need to reference it with that scope:

this.errors.first("s.s1")

Check out the code here: https://baianat.github.io/vee-validate/examples/scopes.html

qhrtzll
  • 76
  • 5