You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nuxt3页面通过NuxtLink导航不加载数据,刷新可正常显示

Nuxt 3.13页面导航时useFetch无法加载数据问题求助

使用Nuxt 3.13结合第三方API开发页面,尝试展示数据时遇到异常:通过NuxtLink进行页面间导航时,目标页面的useFetch函数无法加载数据,仅URL发生变化;但刷新目标页面后,数据可以正常加载。怀疑问题出在路由、服务端/客户端逻辑或生命周期环节,寻求解决方案。

相关代码示例如下:

app.vue

<template>
  <main>
  <page-header />
  <NuxtPage />
</main>
</template>

components/pageHeader.vue

<template>
  <header>
    <nav>
      <NuxtLink  
        to="/buy"
        aria-haspopup="menu"
        aria-expanded="false">
          Buy
        </NuxtLink>      
      <NuxtLink  
        to="/rent" 
        aria-haspopup="menu"
        aria-expanded="false">
          Rent
        </NuxtLink>        
     </nav>
  </header>
</template>

pages/buy/index.vue

<template>
  <section>
    <p>{{ homes.Objects.length }} koopwoningen</p>
    <div v-if="loading">Loading</div>    
    <div v-else-if="error">Sorry, er is iets fout gegaan</div>
    <div v-else-if="homes"
        v-for="home in homes.Objects" 
        :key="home.Adres" 
        
    >{{ home }}</div>>
  </section>
</template>

<script setup>
const {data: homes, loading, error} = useFetch(`https://partnerapi.funda.nl/feeds/Aanbod.svc/json/[key]/?type=koop`)
</script>

控制台存在错误(截图未提供)。注:已移除Tailwind样式以提升可读性,代码中真实API密钥已替换为[key]。

内容的提问来源于stack exchange,提问作者Linda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 13:59:52