Skip to content

Commit 89a4ca1

Browse files
committed
Pass source index to item
1 parent ad2665c commit 89a4ca1

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const VirtualList = Vue.component('virtual-list', {
221221
slots.push(h(Item, {
222222
class: itemClass,
223223
props: {
224+
index,
224225
tag: itemTag,
225226
event: EVENT_TYPE.ITEM,
226227
horizontal: isHorizontal,

src/item.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ export const Item = Vue.component('virtual-list-item', {
5555
props: ItemProps,
5656

5757
render (h) {
58-
const { tag, component, extraProps = {} } = this
58+
const { tag, component, extraProps = {}, index } = this
5959
extraProps.source = this.source
60+
extraProps.index = index
6061

6162
return h(tag, {
6263
role: 'item'

src/props.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export const VirtualProps = {
9595
}
9696

9797
export const ItemProps = {
98+
index: {
99+
type: Number
100+
},
98101
event: {
99102
type: String
100103
},

0 commit comments

Comments
 (0)