antdVue3 封装a-table使用插槽

简单封装a-table组件,只做展示使用

公共table组件

javascript 复制代码
<template>
  <a-table :columns="columns" :data-source="data" bordered size="small" :scroll="scroll">
    <template #bodyCell="{ column, record, index }">
      <template v-if="column.dataIndex === 'index'">
        {{ index + 1 }}
      </template>
      <slot :column="column" :record="record" :index="index"></slot>
    </template>
  </a-table>
</template>

<script setup lang="ts">
import { watch, ref } from 'vue'
let props = defineProps<{ columns: any; data: any; scroll?: object }>()
const columns = props.columns
const data = ref<any>([])
const scroll = props.scroll || {}
data.value = props.data
watch(() => [...props.data], (now, old) => {
  data.value = now
})
</script>
<style scoped></style>

使用组件

数据二次处理。。。等等

javascript 复制代码
  <CommoTable :columns="realitycolumns" :data="realityData" :loading="loading" :scroll="{ y: 300 }"
                :pagination="false">
                <template #default="{ column, record, index }">
                    <template v-if="column.dataIndex === 'unitCode'">
                        {{ unitType[record.unitCode] }}
                    </template>
                </template>
            </CommoTable>
相关推荐
天平3 小时前
油猴脚本创建webworker踩坑记录
前端·javascript·typescript
原则猫5 小时前
前端基础大厦
前端
陈随易6 小时前
编程语言级别的Skill市场,AI Agent 的未来形态
前端·后端·程序员
SoaringHeart7 小时前
Flutter进阶:基于 EasyRefresh 的下拉刷新封装 n_easy_refresh_mixin.dart
前端·flutter
IT_陈寒9 小时前
Vite的热更新突然不香了,排查三小时差点砸键盘
前端·人工智能·后端
子兮曰9 小时前
Agency-Agents 深度解析:400+ AI 专家的"梦之队"如何重塑开发工作流
前端·后端·vibecoding
竹林81810 小时前
用 The Graph 查询链上数据实战:从手搓 RPC 到 Subgraph,我的 NFT 项目数据加载快了 10 倍
前端·javascript
妙码生花10 小时前
从 PHP 到 AI + Golang,程序员自救转型手记(十九):点选验证码代码逐行目检
前端·后端·go
Awu122711 小时前
⚡从零开发 Agent CLI(五)实现一个可治理、可扩展的工具系统
前端·人工智能·claude
咪库咪库咪11 小时前
Vue3-生命周期
前端