数据获取

源码
此示例演示了使用 Nuxt 内置组合式函数和 API 路由进行数据获取。
index.vue
Open docs
<script setup>
const { data } = await useFetch('/api/hello')
</script>

<template>
  <div>
    <p>
      Result of <UKbd
        size="lg"
        value="/api/hello"
      />:
    </p>
    <pre>{{ data }}</pre>
  </div>
</template>
https://data-fetching.example.nuxt.space
Docs > Getting Started > Data Fetching 中查看详情
Docs > Guide > Directory Structure > Server 中查看详情