Skip to content

Instantly share code, notes, and snippets.

@lili668668
Last active August 1, 2019 15:07
Show Gist options
  • Save lili668668/986a17aa3938af77b7d30310f7eeb06f to your computer and use it in GitHub Desktop.
Save lili668668/986a17aa3938af77b7d30310f7eeb06f to your computer and use it in GitHub Desktop.
虛擬滾動表格的解說程式碼
<template>
<div
ref="viewport"
:style="{ height: `${viewportHeight}px` }"
@scroll.passive="onScroll"
>
<div
:style="{ height: `${totalHeight}px` }"
>
<section
:style="{ transform: `translateY(${bodyTranslateY}px)` }"
>
<table
ref="body"
:style="{ height: `${minBodyHeight}px` }"
>
<tbody>
<tr
v-for="(item, index) in renderItems"
ref="row"
:key="index"
>
<td
v-for="(header,i) in headers"
:key="'item'+i"
>
{{ item[header.value] }}
</td>
</tr>
</tbody>
</table>
</section>
</div>
</div>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment