2018-11-06 10:20:49 +00:00
|
|
|
<script>
|
|
|
|
import VirtualList from 'vue-virtual-scroll-list';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'SmartVirtualList',
|
|
|
|
components: { VirtualList },
|
|
|
|
props: {
|
|
|
|
size: { type: Number, required: true },
|
|
|
|
length: { type: Number, required: true },
|
|
|
|
remain: { type: Number, required: true },
|
2020-03-18 15:09:45 +00:00
|
|
|
rtag: { type: String, default: 'div', required: false },
|
|
|
|
wtag: { type: String, default: 'div', required: false },
|
|
|
|
wclass: { type: String, default: null, required: false },
|
2018-11-06 10:20:49 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<virtual-list
|
|
|
|
v-if="length > remain"
|
|
|
|
v-bind="$attrs"
|
|
|
|
:size="remain"
|
|
|
|
:remain="remain"
|
|
|
|
:rtag="rtag"
|
|
|
|
:wtag="wtag"
|
|
|
|
:wclass="wclass"
|
|
|
|
class="js-virtual-list"
|
|
|
|
>
|
|
|
|
<slot></slot>
|
|
|
|
</virtual-list>
|
2018-11-16 20:07:38 +00:00
|
|
|
<component :is="rtag" v-else class="js-plain-element">
|
|
|
|
<component :is="wtag" :class="wclass"> <slot></slot> </component>
|
2018-11-06 10:20:49 +00:00
|
|
|
</component>
|
|
|
|
</template>
|