我有一个电子商务网站,我想循环 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\"]",
感谢您的帮助。