diff --git a/demos/table-mode/App.vue b/demos/table-mode/App.vue
new file mode 100644
index 0000000..aa69fd8
--- /dev/null
+++ b/demos/table-mode/App.vue
@@ -0,0 +1,196 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | {{key}} |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demos/table-mode/index.html b/demos/table-mode/index.html
new file mode 100644
index 0000000..c80f20e
--- /dev/null
+++ b/demos/table-mode/index.html
@@ -0,0 +1,11 @@
+
+
+
+
+ demos\table-mode demo of vue-virtual-scroll-list
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/table-mode/main.js b/demos/table-mode/main.js
new file mode 100644
index 0000000..ec627bb
--- /dev/null
+++ b/demos/table-mode/main.js
@@ -0,0 +1,4 @@
+import App from './App.vue'
+import createApp from '../common/createApp'
+
+createApp(App)
diff --git a/src/index.js b/src/index.js
index c7a5c35..66e0dbf 100644
--- a/src/index.js
+++ b/src/index.js
@@ -99,8 +99,12 @@
type: [Function, Boolean], // Boolean just disable for priviate.
default: false
},
+ isTable: {
+ type: Boolean,
+ default: false
+ },
item: {
- type: Object,
+ type: [Function, Object],
default: null
},
itemcount: {
@@ -504,7 +508,7 @@
const slots = this.$slots.default || []
// item-mode shoud judge from items prop.
- if (this.item) {
+ if (this.item || this.$scopedSlots.item) {
delta.total = this.itemcount
if (delta.keeps > delta.total) {
delta.end = delta.total - 1
@@ -540,7 +544,9 @@
const renders = []
for (let i = delta.start; i < delta.total && i <= Math.ceil(delta.end); i++) {
let slot = null
- if (this.item) {
+ if (this.$scopedSlots.item) {
+ slot = this.$scopedSlots.item(i)
+ } else if (this.item) {
slot = h(this.item, this.itemprops(i))
} else {
slot = slots[i]
@@ -554,12 +560,18 @@
render (h) {
const dbc = this.debounce
- const list = this.filter(h)
+ let list = this.filter(h)
const { paddingTop, paddingBottom } = this.delta
- const renderList = h(this.wtag, {
- style: {
- display: 'block',
+ const isTable = this.isTable
+ const wtag = isTable ? 'div' : this.wtag
+ const rtag = isTable ? 'div' : this.rtag
+ if (isTable) {
+ list = [h('table', [h('tbody', list)])]
+ }
+ const renderList = h(wtag, {
+ 'style': {
+ 'display': 'block',
'padding-top': paddingTop + 'px',
'padding-bottom': paddingBottom + 'px'
},
@@ -574,7 +586,7 @@
return renderList
}
- return h(this.rtag, {
+ return h(rtag, {
ref: 'vsl',
style: {
display: 'block',