Last active
August 15, 2022 17:18
-
-
Save Erefor/51c53dbc52b0f9d439f13959b66e2dc7 to your computer and use it in GitHub Desktop.
Table in Vue 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="ui-table-container"> | |
<table class="ui-table-body"> | |
<thead class="ui-table-heade"> | |
<tr> | |
<th | |
v-for="(column, index) in componentColumns" | |
:key="index" | |
:title="column?.label" | |
class="ui-table-th" | |
> | |
<slot | |
:name="`header-${column.name}`" | |
:column="column" | |
> | |
<p> | |
{{ column?.label }} | |
</p> | |
</slot> | |
</th> | |
</tr> | |
</thead> | |
<tbody v-if="rows && rows.length"> | |
<tr | |
v-for="(row, index) in Rows" | |
:key="index" | |
@click.stop.prevent="$emit('row-action', row)" | |
> | |
<slot | |
:name="`row-item`" | |
:item="row" | |
> | |
<td | |
v-for="(value, key, rowIndex) in row" | |
:key="key" | |
:title="value" | |
> | |
<slot | |
:name="`item-${key}`" | |
:item="{value, key, row, rowIndex, index}" | |
> | |
<p> | |
{{ value }} | |
<p> | |
</slot> | |
</td> | |
</slot> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment