I wanted to make a validation on the match of passwords with the following error:
vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method “$v” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
main.js
import Vue from 'vue'; import Vuelidate from 'vuelidate'; import VueTheMask from 'vue-the-mask'; Vue.use(Vuelidate, VueTheMask); Vue.config.productionTip = false; new Vue({ router, store, vuetify, render: h => h(App) }).$mount('#app')
My form
... <form action="#" method="GET" @submit.prevent="pswResetHendler"> <label class="input__label" for="psw">Yangi parolni kiriting</label> <input class="input input__psw" type="password" name="psw" required v-model="password" :class="{ 'is-invalid': $v.password.$error }" /> <label class="input__label" for="psw">Yangi parolni qayta kiriting</label> <input class="input input__psw" type="password" name="psw" v-model="confirmPassword" :class="{ 'is-invalid': $v.confirmPassword.$error }" /> <span class="input__error match-error" v-if="!$v.confirmPassword.sameAsPassword" >Kiritilgan parollar bir xil bo’lishi lozim, Qayta urinib ko’ring!</span > <button class="login-btn" type="submit">KIRISH</button> </form> ... <script> import { sameAs } from "vuelidate/lib/validators"; export default { name: "password-reset", data() { return { password: "", confirmPassword: "", }; }, methods: { pswResetHendler() { this.$v.$touch(); if (this.$v.$invalid) { return; } this.$router.push("/"); }, }, validation: { confirmPassword: { sameAsPassword: sameAs("password") }, }, }; </script>
Please help me guys I can’t solve this for a day ((((
Advertisement
Answer
I’m really sorry guys )
I wrote the property validations
incorrectly. I wrote
validation: { confirmPassword: { sameAsPassword: sameAs("password") }, },
instead of this I had to write
validations: { confirmPassword: { sameAsPassword: sameAs("password") }, },