简体   繁体   中英

How to get index in pagination vuejs?

I'm trying pagination in vuejs & My code in fiddle

v-for="(number, item) in items | filterBy name in 'name' | limitBy count offset"

my quetion is how can get index in pagination?

for example : I have data in paging or page one :

index :"1" - Kathy Sparks

index :"2" - Gladys Tate

and then if I'm click paging two, I want to index continue

index : 3 - Shannon

index : 4 - Rosetta Scott

I would suggest putting the output of each item into a child component and passing the index of that item in the array as a param. There are other ways to do it, such as passing the item from your vue template into a method and looking up the index of the field, eg:

// vue template
{{ whatIndex(item) }}

// vue js
vue.methods.whatIndex = function (item) { 
  // some logic to lookup the name from this.items
  return i
}

最快的方法:

{{number + offset + 1}} - {{item.name}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM