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

前端 未结 3 603
一整个雨季
一整个雨季 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:50

    you can try this solution to...

    ....

    and set your limit in data

    data() {
      return {
        limitationList:5
      };
    },
    

    and set a function in you btn

      
    

    and this your methods

    updateLimitation(limitationList){
      if (this.limitationList == this.items.length) {
        this.limitationList = 5
      }else{
        this.limitationList = this.items.length
      }
    }
    

    i hope useful for you...

提交回复
热议问题