feat: pure-table添加headerSlot自定义表头插槽用法示例

This commit is contained in:
xiaoxian521 2024-04-06 12:25:13 +08:00
parent bf874276f3
commit c0a1b918aa
4 changed files with 15 additions and 7 deletions

View File

@ -26,7 +26,7 @@ const props = withDefaults(defineProps<FormProps>(), {
path: "", path: "",
component: "", component: "",
rank: 99, rank: 99,
redirect: " ", redirect: "",
icon: "", icon: "",
extraIcon: "", extraIcon: "",
enterTransition: "", enterTransition: "",

View File

@ -61,7 +61,7 @@ const {
</el-form> </el-form>
<PureTableBar <PureTableBar
title="菜单管理(初版,持续完善中" title="菜单管理(仅演示,操作后不生效"
:columns="columns" :columns="columns"
:isExpandAll="false" :isExpandAll="false"
:tableRef="tableRef?.getTableRef()" :tableRef="tableRef?.getTableRef()"

View File

@ -2,7 +2,6 @@ import { message } from "@/utils/message";
import { tableData } from "../data"; import { tableData } from "../data";
import { ref, computed } from "vue"; import { ref, computed } from "vue";
// 如果您不习惯tsx写法可以传slot然后在template里写
// 需是hooks写法函数中有return避免失去响应性 // 需是hooks写法函数中有return避免失去响应性
export function useColumns() { export function useColumns() {
const search = ref(""); const search = ref("");
@ -26,8 +25,9 @@ export function useColumns() {
const columns: TableColumnList = [ const columns: TableColumnList = [
{ {
label: "日期", prop: "date",
prop: "date" // 自定义表头slot用法 #nameHeader="{ column, $index }"
headerSlot: "nameHeader"
}, },
{ {
label: "姓名", label: "姓名",
@ -39,7 +39,7 @@ export function useColumns() {
}, },
{ {
align: "right", align: "right",
// 自定义表头 // 自定义表头tsx用法
headerRenderer: () => ( headerRenderer: () => (
<el-input <el-input
v-model={search.value} v-model={search.value}

View File

@ -1,9 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { useColumns } from "./columns"; import { useColumns } from "./columns";
import Calendar from "@iconify-icons/ri/calendar-2-line";
const { columns, filterTableData } = useColumns(); const { columns, filterTableData } = useColumns();
</script> </script>
<template> <template>
<pure-table :data="filterTableData" :columns="columns" /> <pure-table :data="filterTableData" :columns="columns">
<template #nameHeader>
<span class="flex items-center">
<IconifyIconOffline :icon="Calendar" />
日期
</span>
</template>
</pure-table>
</template> </template>