当前位置: 首页 > article >正文

el-table 对循环产生的空白列赋默认值

1. el-table 空白列赋值

对el-table中未传数据存在空白的列赋默认值0。使用el-table 提供的插槽 slot-scope:{{ row || ‘0’ }}
原数据:
在这里插入图片描述

<el-table-column label="集镇"  :prop=city >
     <template slot-scope="{row}">
         {{ row || '0' }}
       </template>
</el-table-column>

2.el-table 对循环产生的空白列赋值

对于循环产生的列,仍要赋默认值0,可采用以下方式: {{ row[col.city] || ‘0’ }}
原数据:
在这里插入图片描述

<template v-for="col in cols">
   <el-table-column :label=col.label>
     <el-table-column label="集镇" :prop=col.city >
       <template slot-scope="{row}">
         {{ row[col.city] || '0' }}
       </template>
     </el-table-column>
     <el-table-column label="农村" :prop=col.village>
       <template slot-scope="{row}">
         {{ row[col.village] || '0' }}
       </template>
     </el-table-column>       
   </el-table-column>
</template>

问题解决:
在这里插入图片描述


http://www.kler.cn/news/136011.html

相关文章:

  • 论文笔记:The Impact of AI on Developer Productivity:Evidence from GitHub Copilot
  • 怎么在echarts图上左右滑动切换数据区间
  • Flutter在web项目中使用iframe
  • html主页框架,前端首页通用架构,layui主页架构框架,首页框架模板
  • 设计原则 | 开放封闭原则
  • LeetCode【92】翻转链表II
  • 将Excel中的数据导入shell脚本
  • 用java编写图书管理系统
  • HDCTF2023 - Reverse方向全WP
  • 在Oracle 11g 数据库上设置透明数据加密(TDE)
  • 【SpringCloud】Eureka基于Ribbon负载均衡的调用链路流程分析
  • BLIP-2:冻结现有视觉模型和大语言模型的预训练模型
  • C#具名参数(Named Parameters)
  • Ubuntu下发送邮件
  • C#编程题分享(1)
  • 【亚马逊云科技产品测评】活动征文|aws云服务器 + 微服务Spring Cloud Nacos 实战
  • 使用Java解决快手滑块验证码
  • unity 打包exe设置分辨率
  • 线上bug-接口速度慢
  • Spring Boot - 自定义注解来记录访问路径以及访问信息,并将记录存储到MySQL
  • 解决 Python requests 库中 SSL 错误转换为 Timeouts 问题
  • 使用 Core Tools 在本地开发 Azure Functions
  • 【图数据库实战】-HugeGraph系列
  • SpringCloud 微服务全栈体系(十四)
  • 【brpc学习案例实践一】rpc服务构造基本流程
  • 彻底解决electron-builder安装问题与npm下载配置问题
  • Docker发布简单springboot项目
  • C++ 删除无头链上所有指定值为x的节点。
  • Redis设计与实现-数据结构(建设进度15%)
  • Re50:读论文 Large Language Models Struggle to Learn Long-Tail Knowledge