Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams <div v-for="elem in arr"> // here i need to produce a div every 4 steps // each div will contain 4 elements in right order </template> <script> export default { name:home, data(){ return { arr:[1,2,3,4,5,6,7,8,9], </script>

So I get 3 div and each one contains 4 elements.

const result = [] for (let i = 0; i < this.arr.length; i += 4) result.push(this.arr.slice(i, i + 4)) return result

In the template:

<div v-for="a in chunkedArr">
    <div v-for="i in a">{{ i }}</div>
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.