相关疑难解决方法(0)

Nuxt 如何在数组上循环并使用 v-for 正确显示数据

我有一个电子商务网站,我想循环 json 中的嵌套数据。我尝试了很多东西但找不到。

async fetch() {
    this.post = await fetch(
      `http://test.com/api.php?id=${this.$route.params.id}`
    ).then((res) => res.json())
  }
Run Code Online (Sandbox Code Playgroud)

我这样使用;

<h3>{{ post.title }}</h3>
<li v-for="(index, post.sizes) in sizes" :key="index">
        {{ sizes.index }}
      </li>
Run Code Online (Sandbox Code Playgroud)

我的 json 数据是:"sizes": "[\"XS\",\"S\",\"M\",\"L\"]",

感谢您的帮助。

json vue.js nuxt.js

2
推荐指数
1
解决办法
4798
查看次数

标签 统计

json ×1

nuxt.js ×1

vue.js ×1