Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
619 B
3
Indexable
Never
<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