Answer the question
In order to leave comments, you need to log in
How to take the first 5 elements in each category?
<template v-for="article in articles">
<article
v-if="article.category.name == data.name"
:key="article.id"
class="article-thumb"
>
Answer the question
In order to leave comments, you need to log in
Something like:
StackOverflow
let articlesGroups = articles.reduce((articles, item) => {
let article = (articles[item.category] || []);
article.push(item);
articles[item.category] = article;
return articles;
}, {});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question