Untitled
<script setup> import { reactive, computed, onMounted } from "vue"; import { useRouter } from "vue-router"; import { required, email } from "@vuelidate/validators"; import { useVuelidate } from "@vuelidate/core"; const router = useRouter(); const state = reactive({ email: "", password: "", }); const stateRules = computed(() => { return { email: { required, email }, password: { required }, }; }); const v$ = useVuelidate(stateRules, state); const login = onMounted(() => { this.v$.$validate(); if (this.v$ === state) { alert("successful"); } else { alert("wrong"); } }); </script>
Leave a Comment