ant-design-vue的table组件的自定义表头和表格内容

使用a-table组件时,有时候需要自定义表头以及表格内容
1、自定义表格内容

// html
 <template slot="alarmTime" slot-scope="text, scope">
   <span v-if="warningType === '0'">{
   {
    scope.alarmTime}}</span>
   <span v-else></span>
 </template>
 // js
data() {
   
	return {
   
		columns: [
			{
   
				title: '告警时间',
	            dataIndex: 'alarmTime',
	            scopedSlots: {
    customRender: 'alarmTime' },// 表格内容插槽
	            align: 'center'
	        },
		]
	}
}

2、自定义表格表头

<template slot="customAlarmTimeTitle">
  <span>发生时间</span>
  <span>
    <a-icon type="caret-up" />
    <a-icon type="caret-down" />
  </span>
</template>
 <template slot="alarmTime" slot-scope="text, scope">
   <span v-if="warningType === '0'">{
   {
    scope.alarmTime}}</span>
   <span v-else></span>
 </template>
 // js
data() {
   
	return {
   
		columns: [
			{
   
				// title: '告警时间',// 注意,此时不能给title值了,否则会优先展示title的值,导致slots配置无效
	            dataIndex: 'alarmTime',
	            slots: {
    title: 'customAlarmTimeTitle' },// 表头插槽
	            scopedSlots: {
    customRender: 'alarmTime' },// 表格内容插槽
	            align: 'center'
	        },
		]
	}
}

最近更新

  1. TCP协议是安全的吗?

    2024-01-12 21:32:05       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-12 21:32:05       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-12 21:32:05       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-12 21:32:05       20 阅读

热门阅读

  1. flask web学习之模板(二)

    2024-01-12 21:32:05       32 阅读
  2. 原型和原型链

    2024-01-12 21:32:05       34 阅读
  3. [渗透测试学习] Crocodile - HackTheBox

    2024-01-12 21:32:05       36 阅读
  4. linux 安装redis

    2024-01-12 21:32:05       39 阅读
  5. [DM8] 查看当前执行的查询并杀死

    2024-01-12 21:32:05       37 阅读
  6. Postman应用打开超级慢解决办法

    2024-01-12 21:32:05       33 阅读
  7. Unity实现 球形雾效散射光照

    2024-01-12 21:32:05       39 阅读
  8. Compose中使用paging3进行列表分页加载Room中的数据

    2024-01-12 21:32:05       40 阅读
  9. 数据库-列的类型-字符串char类型

    2024-01-12 21:32:05       38 阅读
  10. redis前缀匹配数据迁移数据

    2024-01-12 21:32:05       38 阅读