nuxt js useFetch() 未在我的浏览器中显示数据

问题描述 投票:0回答:1

它没有在我的网站中显示数据。有什么问题我找不到它。请帮助我,对不起。 url 包含 json 数据并包含“featured”键。下面是我的代码。

<template>
   <q-card v-for="article in formattedJSON.featured" :key="article.id">
    <q-img :src="article.image" @load="imageLoaded" />
     <q-card-section>
      <NuxtLink
       :to="article.channel.url"
        class="text-channel text-caption q-mb-sm text-uppercase text-weight-bold"
        style="text-decoration: none"
        >{{ article.channel.name }}
     </NuxtLink>
      <p class="q-mb-sm text-header4">{{ article.title }}</p>
     <p class="q-mb-xl text-data">{{ article.blurb }}</p>
   </q-card-section>
  </q-card>
</template>

<script setup>
 const { data: formattedJSON } = await useFetch(
 "https://featured/get/");
</script>`

在页面中显示图像、频道名称、标题和简介等数据。

javascript vue.js nuxt.js nuxt3 usefetch
1个回答
0
投票

您可能想尝试使用 JSON.parse(formattedJSON.featured),因为特色数据可能不是预期的对象格式。

© www.soinside.com 2019 - 2024. All rights reserved.