Vee-validate error object - _vm.errors undefined

This is my .vue component file, which I should not have used Vue.use()to install the verification package vee-validate. The module, as indicated in the documents, will inject the object errorsinto the object data.

But I get an error _vm.errors is undefined. I am not sure if I am creating it correctly.

In addition, whether import Vue from 'Vue'and Vue.use(VeeValidate)to use vee-validate only for this component? (which is what I want to do).

<template>
<input class="form-control" name="name" placeholder="Name" type="text" v-model="player.name" v-validate data-vv-rules="alpha|min:2|max:50" :class="{'input': true, 'is-danger': errors.has('name') }">
</template>

<script>
import Vue from 'Vue';
import VeeValidate from 'vee-validate';
Vue.use(VeeValidate);

export default {
  data() {
    return {
      // errors: '',
      showForm: false,
      player: null
    }
  }
}
</script>
+1
source share
1 answer

I had a similar problem, but I am using the following versions:

"vee-validate": "^ 2.0.0-rc.21", "vue": "^ 2.5.2",

, : this. $validator.error

. vee-validate: http://vee-validate.logaretm.com/api.html#error-bag

, :

Vue $validator. . .

+1

Source: https://habr.com/ru/post/1663145/


All Articles