先感谢您。
所以我通过获取博客类别API
列表并使用v-for
.
我还需要获取每个类别中的博客数量并将它们放在类别旁边。
但问题是我正在调用一个调用api
.
<li v-for="item in sidebar" :key="item.identifier">
<nuxt-link
tag="a"
:to="{
name: 'blog-page',
query: { category: item.identifier }
}"
>{{ $localize(item.translations).title }}
{{ getBlogCount(item.identifier) }}
</nuxt-link>
</li>
你知道它已经显示的例子是Animals [Object Promise]
methods: {
async getBlogCount(identifier) {
axios
.get(
"https://example.com/posts?fields=created_at&filter[category.category_id.identifier]=" +
identifier +
"&meta=*"
)
.then(count => {
return count.data.meta.result_count;
});
}
}
处理这种事情的最佳方法是什么?