1、需求:单元格中的内容需要循环渲染,如图

2、后台返回的数据格式为:


3、刚开始使用的是这样:
<template slot="conditionsArr" slot-scope="text, record">
<ul class="conditonBox"><li v-for="(item, index) in record.conditionsArr" :key="index"><div class="listBox"><span class="listId">{{ index + 1 }}</span><span class="listContent">{{ item.prop1 }}</span><span class="listContent">{{ item.exp }}</span><span class="listContent">{{ item.val }}</span><span class="listContent" style="margin-left: 0px">{{item.unit}}</span><span class="listContent">{{item.prop2}}</span><span class="listContent">{{ item.prop3 }}</span></div></li></ul>
</template>
4、返回表格:


5、然后只能一层一层去拿数据了
<template slot="conditionsArr" slot-scope="text, record"><span>{{ record }}</span>
</template>
6、表格渲染出来的是空的

7、换个数据
<template slot="conditionsArr" slot-scope="text, record"><span>{{ text }}</span>
</template>
8、有数据了


放到json工具

9、问题解决:
<template slot="conditionsArr" slot-scope="text"><ul class="conditonBox"><li v-for="(item, index) in text.record.conditionsArr" :key="index"><div class="listBox"><span class="listId">{{ index + 1 }}</span><span class="listContent">{{ item.prop1 }}</span><span class="listContent">{{ item.exp }}</span><span class="listContent">{{ item.val }}</span><span class="listContent" style="margin-left: 0px">{{item.unit}}</span><span class="listContent">{{item.prop2}}</span><span class="listContent">{{ item.prop3 }}</span></div></li></ul>
</template>
10、效果:

11、可能是后台返回的格式不同,或者是我们的习惯不同,但是只要先一步一步拿到数据,终究结果都是一样的。
12、追加:如果对单元格的数据无操作直接渲染,则定义dataIndex; 如果单元格的数据都是一个一个去拿到,则没必要(自定义siteInfo,页面通过record则拿到当前行的数据)
html
<template slot="siteInfo" slot-scope="record"><ul class="infoBox"><li><span>测站编码:{{record.devId}}</span><span>测站名称:{{record.name}}</span><span>测站地址:{{record.address}}</span></li></ul>
</template>
js
{title: "异常监测数据",dataIndex: "outliers",align: "center"},{title: "测站信息",align: "center",scopedSlots: {customRender: "siteInfo",},},
13、如果是直接使用,可以这么写:
{title: "季度",dataIndex: 'quarter',scopedSlots: {customRender: "quarter",},
},
<span slot="quarter" slot-scope="record"><span>{{ record.text? '第' + record.text + '季度': '--'}}</span>
</span>
14、注意dataIndex、scopedSlots同时存在的时候,直接取值需要record.text
15、还有其它情况,就是dataIndex、scopedSlots同时存在,直接拿到值做判断
const columns = [{title: '季度',scopedSlots: { customRender: 'quarter' }},{title: '经办人',dataIndex: 'operatorName',scopedSlots: { customRender: 'operatorName' }}
]<!-- 拿到当前行对象 -->
<span slot="quarter" slot-scope="row">第{{row.quarter}}季度</span>
<!-- 直接使用 -->
<span slot="operatorName" slot-scope="text">{{text||'--'}}</span>
16、总结:看后台返回怎样的数据,然后自己的需求又是如何的,一步一步去取

5.12 汶川13周年 少年犹在,祖国安泰!

Ant Design of Vue表格中slot-scope=“text, record”相关推荐

  1. Ant Design of Vue 表格使用 vue-draggable-resizable 封装表头问题汇总

    背景 项目需要表格支持拉伸每列的宽度,查看了文档,官方建议是用 vue-draggable-resizable 插件结合 components 属性,给表头 header 增加一个可拖拽的功能.其实下 ...

  2. ant design vue 表格中时间戳转换成时间格式显示

    ant design vue 表格中时间戳转换成时间格式显示 原始数据表格如上图,因为接口传递过来的时间是10位int类型的时间戳格式,所以前端需要我们把时间格式化. step1 安装moment n ...

  3. 使用Ant Design 和Vue,React中后台开发套餐

    2019独角兽企业重金招聘Python工程师标准>>> 前言 目前Ant Design 提供 React 和 Vue 两种整合开发框架,开箱即用的中台前端/设计解决方案,可适合中小公 ...

  4. 标题Ant Design of Vue 组件库中Modal“确认“按钮和“取消“按钮成英文状态

    标题Ant Design of Vue 组件库中Modal"确认"按钮和"取消"按钮成英文状态 因为是国际化的原因,造成确定按钮和取消按钮变成英文,需要设置 o ...

  5. Vue.js高效前端开发 • 【Ant Design of Vue框架进阶】

    全部章节 >>>> 文章目录 一.栅格组件 1.栅格组件介绍 2.栅格组件使用 3.实践练习 二.输入组件 1.输入框组件使用 2.选择器组件使用 3.单选框组件使用 4.实践 ...

  6. Ant Design of Vue +TS 表单动态增加数据验证卧坑姿势

    文章目录 Update 20210601 Update 20210525 原文: 1.a-form的model 2.获取数据 源码 Update 20210601 今天做别的页面的时候发现又取不到数据 ...

  7. ant design pro vue左侧菜单自定义图标

    做ant design pro vue项目的时候突然想修改左侧菜单的图标,在修改途中发现源码中提供的方法方法居然不生效(如下所示) 在src/assets/icons文件夹中下载svg图标 在src/ ...

  8. Vue表格中,对数据进行转换、处理

    众所周知,后端从Mysql取出的数据,一般是很难单独处理某一个Key的数据的(需要处理的话,可能会浪费大量的性能.而且对页面加载时间有很大的影响),所以,从数据库取出的数据.只能由前端进行处理.但是在 ...

  9. 创建Vue+TS+Ant Design of Vue 项目

    创建Vue+TS+Ant Design of Vue 项目 创建项目 选择配置 运行项目 安装 ant-design-vue 安装 babel-plugin-import 使用VS Code打开 配置 ...

最新文章

  1. log4j的日志级别(ssm中log4j的配置)
  2. CAS SSO对手机应用支持的一种思路
  3. 2015!我来了,你在哪里?今年第一篇
  4. pku acm 2248 addtion chians 解题报告
  5. 东风小康为什么是dfsk_助力地摊经济瑞驰纯电动物流车和东风小康微型货车厚积薄发...
  6. shell 字符串删除特定字符
  7. 参数变化_光纤激光切割机操作和工艺参数变化对质量的影响
  8. intellij idea rearrange code
  9. 绵阳市:充分利用区块链等技术 为农民工证照办理提供线上便捷服务
  10. HTML5 Input 日期选择器
  11. Excel选择下拉匹配
  12. 福利:推荐一个免费的抠图网站
  13. mysql数据库存图片名_【mysql】数据库存图片,是存图片名称?还是存图片路径??...
  14. 帆软数据决策系统漏洞_帆软报表漏洞总结
  15. SpringBoot中全面接管SpringMVC
  16. python安装环境相关,已被坑过
  17. python如何安装pil库_Python安装PIL库
  18. 小程序图片懒加载放在服务器,【小程序】使用uni-app搭建小程序环境---图片懒加载...
  19. 智能指纹锁办理3C认证多少钱
  20. 公司用的 MySQL 团队开发规范,太详细了

热门文章

  1. oracle all_tab_columns,[20120507]视图all_tab_columns的定义问题.txt
  2. PointPillars点云检测在OpenPCDet推理代码详解
  3. 【数据结构实验】链表的创建与功能的实现
  4. ROS SMACH个人学习记录
  5. 北美电影票房Top10-2020年1月31日:《绝地战警3》三连冠
  6. 鸟哥的Linux私房菜——第十章
  7. IOS学习之路二十四(custom 漂亮的UIColor)
  8. swoole http请求出现1004 1005报错
  9. 基于SSM的企业公司财务管理(javaweb-php-asp.netC#-j2ee)包含资产管理-凭证管理-出纳往来管理-年终资产数据统计分析
  10. 逆序链表从m到n位置