How to limit iteration of elements in `v-for`

前端 未结 3 610
一整个雨季
一整个雨季 2020-12-08 02:10

I\'m building a small application in Vuejs 2.0 I\'m having approx 15 iterating elements I want to limit the v-for for only 5 elements and can have

3条回答
  •  余生分开走
    2020-12-08 02:47

    You can try this code

    You will only have 5 elements in the new array.

    Update: Tiny change that makes this solution work with both arrays and objects

提交回复
热议问题