Skip to content

Commit 33fb0e5

Browse files
committed
refactor: improve route
1 parent 2ed9eae commit 33fb0e5

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

pages/hi/[id].vue

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { useUserStore } from '~/stores/user'
3+
34
const route = useRoute()
45
const user = useUserStore()
56
const name = route.params.id
@@ -9,35 +10,24 @@ watchEffect(() => {
910
</script>
1011

1112
<template>
12-
<div>
13-
<h3>
14-
Hi,
15-
</h3>
16-
<div>
17-
{{ name }}!
18-
</div>
13+
<div m-3>
14+
<h3>Hi, {{ name }}!</h3>
1915

2016
<template v-if="user.otherNames.length">
21-
<p>
22-
<span>Also as known as:</span>
23-
<ul>
24-
<li v-for="otherName in user.otherNames" :key="otherName">
25-
<router-link :to="`/hi/${otherName}`" replace>
26-
{{ otherName }}
27-
</router-link>
28-
</li>
29-
</ul>
30-
</p>
17+
<span>Also as known as:</span>
18+
<ul>
19+
<li v-for="otherName in user.otherNames" :key="otherName">
20+
<router-link :to="`/hi/${otherName}`" replace>
21+
{{ otherName }}
22+
</router-link>
23+
</li>
24+
</ul>
3125
</template>
3226

3327
<Counter />
3428

3529
<div>
36-
<NuxtLink
37-
to="/"
38-
>
39-
Back
40-
</NuxtLink>
30+
<NuxtLink to="/">Back</NuxtLink>
4131
</div>
4232
</div>
4333
</template>

0 commit comments

Comments
 (0)