-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseTable.vue
45 lines (44 loc) · 1.11 KB
/
BaseTable.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<script setup lang="ts">
interface Props<T> {
headers: object,
data: T
}
defineProps<Props<any>>()
</script>
<template>
<div class="mx-auto">
<div class="overflow-x-auto overflow-y-visible scroll">
<table class="w-full ">
<thead class="border border-[#C9CCCF]">
<tr>
<th
v-for="(header, index) in Object.values(headers)"
:key="index"
scope="col"
class="text-xs font-medium px-6 py-2.5 whitespace-nowrap text-left"
>
{{ header }}
</th>
</tr>
</thead>
<tbody>
<tr
v-for="(item, i) in data"
:key="i"
class="border border-[#C9CCCF] align-top"
>
<td
v-for="key in Object.keys(headers)"
:key="key"
class="text-sm font-medium px-6 py-2.5 whitespace-nowrap"
>
<slot :name="key" v-bind="item">
{{ item[key] }}
</slot>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>