尝试在单个文件组件中使用 vuelidate 插件时遇到一些问题
app.js
import Vue from 'vue';
import Vuelidate from 'vuelidate';
Vue.use(Vuelidate)
const T = new Vue({
router: router,
template: '<div id="app"><heading></heading><transition :css="false" mode="out-in" @enter="enter" @leave="leave"><router-view></router-view></transition></div>',
data: {
currentRoute: window.location.href,
},
created(){
this.$watch('$v', () => {
console.log('$v changed')
})
},
validations: {}
}).$mount('#app');
--
<template>
<form id="registration" class="form form_bl " @submit="handleSubmit" action="">
<input type="email" v-model="email" name="email" class="inp m30_b" placeholder="E-mail">
<button class="btn">Send</button>
</template>
import { validationsMixin } from 'vuelidate';
import { required, minLength } from 'vuelidate/lib/validators';
export default {
data () {
return {
email: ''
}
},
validations: {
email: {
required,
}
},
methods: {
handleSubmit: function(e) {
e.preventDefault();
console.log($v.email);
}
}
}
我刚刚得到 $v 没有定义,我尝试了一切
重新排序组件包括 .vue 文件中的 Vuelidate
但没有任何帮助