Add route to get a particular book
This commit is contained in:
32
front/src/BookForm.vue
Normal file
32
front/src/BookForm.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<script setup>
|
||||
import { getBook } from './api.js'
|
||||
import { onBeforeRouteUpdate } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
id: String
|
||||
});
|
||||
|
||||
let { data, error } = getBook(props.id);
|
||||
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
let res = getBook(to.params.id);
|
||||
data = res.data;
|
||||
error = res.error;
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<pre>{{ data }}</pre>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
img {
|
||||
max-height:500px;
|
||||
max-width:500px;
|
||||
height:auto;
|
||||
width:auto;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user