Nuxt/examples/async-data/pages/index.vue

20 lines
319 B
Vue
Raw Normal View History

2021-04-23 20:30:43 +00:00
<template>
<div>
Page visits: {{ data.count }}
</div>
</template>
<script lang="ts">
import { defineNuxtComponent, asyncData } from '@nuxt/app'
export default defineNuxtComponent({
setup () {
const { data } = asyncData('time', () => $fetch('/api/count'))
return {
data
}
}
})
</script>