-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.vue
38 lines (33 loc) · 976 Bytes
/
app.vue
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
<template>
<p>{{ greeting }}</p>
<NuxtLink :to="`?x=${y}&y=${x}`">Reverse</NuxtLink>
</template>
<script lang="ts" setup>
// Gather function arguments from route's query (and use fallback values if not given)
const route = useRoute()
const x = computed(() => route.query.x?.toString() ?? "Backend")
const y = computed(() => route.query.y?.toString() ?? "Frontend")
const { data: greeting } = useAsyncData(
// Make a function call using Prim+RPC (`useAsyncData` is Nuxt's way of handling returned promise)
() => backend.sayHello(x.value, y.value),
// Optionally, pass references to `.watch` option of `useAsyncData` if you'd like to refetch on value changes
{ watch: [x, y] }
)
useHead({ title: greeting })
</script>
<style>
html {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #000;
color: #fff;
font-size: 2rem;
font-family: sans-serif;
text-align: center;
}
a {
color: #aaa;
}
</style>