1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <script setup>
|
| import {useRoute} from 'vue-router'
| import {onMounted, reactive, ref} from "vue"
|
| const route = useRoute()
| const userId = route.params.userId
| const users = reactive({
|
| })
| const error = ref(null)
|
| onMounted(init)
|
| /////////////////////////////////////////////////////////////////////////
|
| async function init() {
| const res = await fetch(`/user/${userId}`)
| console.log(res)
| if(res.status === 200) {
| users = res.data
| }
| else {
|
| }
| }
|
| </script>
|
| <template>
|
| <div>
| <h1>User Detail</h1>
| <p>{{userId}}</p>
| <p v-if="error">{{error}}</p>
| <pre>{{users}}</pre>
| </div>
|
| </template>
|
| <style scoped>
|
| </style>
|
|