Second commit
added few test, first api to add book
This commit is contained in:
41
front/src/AddBook.vue
Normal file
41
front/src/AddBook.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { postBook } from './api.js'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const book = ref({
|
||||
title: "",
|
||||
author: ""
|
||||
});
|
||||
|
||||
function onSubmit(e) {
|
||||
postBook(book);
|
||||
router.push('/');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<form @submit.prevent="onSubmit">
|
||||
<div class="field">
|
||||
<label class="label">Title</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" v-model="book.title" placeholder="Title">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">Author</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" v-model="book.author" placeholder="Author">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button class="button is-link">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user