Skip to content

格式化

-
-
---undefined---
vue
<template>
  <TableGenerator ref="RefTableGenerator" v-bind="{ ...tableAttrs }" />
</template>

<script lang="tsx" setup>
import { TableGenerator } from 'element-plus-generator'
import type { TableAttrs, RefTableGenerator } from 'element-plus-generator/lib/type'
import { ref, onMounted } from 'vue'

const RefTableGenerator = ref<RefTableGenerator>()
const tableAttrs = ref<TableAttrs>({
  data: [
    {
      date: '2016-05-03',
      name: 'Tom',
      address: 'No. 189, Grove St, Los Angeles',
    },
    {
      date: '2016-05-02',
      name: 'Tom',
      address: 'No. 189, Grove St, Los Angeles',
    },
    {
      date: '2016-05-04',
      name: 'Tom',
      address: 'No. 189, Grove St, Los Angeles',
    },
    {
      date: '2016-05-01',
      name: 'Tom',
      address: 'No. 189, Grove St, Los Angeles',
    },
  ],
  tableOption: [
    {
      prop: 'date',
      label: 'Date',
      width: '180'
    }, {
      prop: 'name',
      label: 'Name',
      width: '180'
    }, {
      prop: 'address',
      label: 'Address',
      formatter: (scope: { $index: number, row: Record<string, any> }) => {
        return `---${scope.row.address}---`
      }
    },
  ]
})

onMounted(() => {
  console.log(RefTableGenerator.value());
})
</script>