From f206782c07ab0f4439b52e4f619d1649a72b6d9b Mon Sep 17 00:00:00 2001 From: Den Great Date: Thu, 21 May 2020 16:14:49 +0800 Subject: [PATCH 1/2] for item component --- README.md | 6 ++++++ src/index.js | 5 +++-- src/item.js | 5 +++-- src/props.js | 6 ++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0b1c282..460be77 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,12 @@ More usages or getting start you can refer to these clearly [examples](https://g {} For using using footer slot, footer slot wrapper element inline style. + + scoped-slots + Object + {} + $scopedSlots for item component + diff --git a/src/index.js b/src/index.js index 8ca3b82..540a995 100644 --- a/src/index.js +++ b/src/index.js @@ -263,7 +263,7 @@ const VirtualList = Vue.component('virtual-list', { getRenderSlots (h) { const slots = [] const { start, end } = this.range - const { dataSources, dataKey, itemClass, itemTag, itemStyle, isHorizontal, extraProps, dataComponent } = this + const { dataSources, dataKey, itemClass, itemTag, itemStyle, isHorizontal, extraProps, dataComponent, scopedSlots } = this for (let index = start; index <= end; index++) { const dataSource = dataSources[index] if (dataSource) { @@ -277,7 +277,8 @@ const VirtualList = Vue.component('virtual-list', { uniqueKey: dataSource[dataKey], source: dataSource, extraProps: extraProps, - component: dataComponent + component: dataComponent, + scopedSlots: scopedSlots }, style: itemStyle, class: `${itemClass}${this.itemClassAdd ? ' ' + this.itemClassAdd(index) : ''}` diff --git a/src/item.js b/src/item.js index 023a13d..ad495d8 100644 --- a/src/item.js +++ b/src/item.js @@ -51,7 +51,7 @@ export const Item = Vue.component('virtual-list-item', { props: ItemProps, render (h) { - const { tag, component, extraProps = {}, index } = this + const { tag, component, extraProps = {}, index, scopedSlots = {} } = this extraProps.source = this.source extraProps.index = index @@ -60,7 +60,8 @@ export const Item = Vue.component('virtual-list-item', { role: 'item' } }, [h(component, { - props: extraProps + props: extraProps, + scopedSlots })]) } }) diff --git a/src/props.js b/src/props.js index 96fc35c..52ccf7c 100644 --- a/src/props.js +++ b/src/props.js @@ -102,6 +102,9 @@ export const VirtualProps = { }, footerStyle: { type: Object + }, + scopedSlots: { + type: Object, } } @@ -129,6 +132,9 @@ export const ItemProps = { }, extraProps: { type: Object + }, + scopedSlots: { + type: Object, } } From 01091191e11aa3aa993871348830b9662fd73268 Mon Sep 17 00:00:00 2001 From: Den Great Date: Thu, 21 May 2020 16:19:42 +0800 Subject: [PATCH 2/2] code style fix --- src/item.js | 2 +- src/props.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/item.js b/src/item.js index ad495d8..0141f05 100644 --- a/src/item.js +++ b/src/item.js @@ -61,7 +61,7 @@ export const Item = Vue.component('virtual-list-item', { } }, [h(component, { props: extraProps, - scopedSlots + scopedSlots: scopedSlots })]) } }) diff --git a/src/props.js b/src/props.js index 52ccf7c..2c8a919 100644 --- a/src/props.js +++ b/src/props.js @@ -104,7 +104,7 @@ export const VirtualProps = { type: Object }, scopedSlots: { - type: Object, + type: Object } } @@ -134,7 +134,7 @@ export const ItemProps = { type: Object }, scopedSlots: { - type: Object, + type: Object } }