signIn.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <script sepup>
  2. import { ref } from 'vue';
  3. const login = ref(''), password = ref('');
  4. let errorForm = ref('');
  5. if(login.value && password.value){
  6. try {
  7. const submitForm = async () => {
  8. const {data} = await $fetch('/api/signIn', {
  9. method: 'post',
  10. body: {
  11. login: login.value,
  12. password: password.value
  13. }
  14. })
  15. }
  16. } catch (error) {
  17. console.log('signIn', error);
  18. }
  19. }else{
  20. errorForm.value = 'Заполните поля'
  21. }
  22. </script>
  23. <template>
  24. <section class="d-flex justify-content-center align-items-center flex-column">
  25. <form @submit.prevent="submitForm()" class="d-flex flex-column gap-3">
  26. <h1>авторизация</h1>
  27. <input class="p-1" type="text" placeholder="Логин" v-model="login">
  28. <input class="p-1" type="password" placeholder="Пароль" v-model="password">
  29. <button type="submit" class="btn btn-primary">Авторизироватся</button>
  30. </form>
  31. </section>
  32. </template>
  33. <style scoped>
  34. form{
  35. width: 450px;
  36. }
  37. </style>