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 {
showForm: false,
player: null
}
}
}
</script>
source
share