当前位置:网站首页>el-table的formatter属性的用法
el-table的formatter属性的用法
2022-07-26 09:21:00 【周小盗】
一、formatter是什么?
formatter是el-table-column的一个属性,用来格式化内容。(比如后台给你返0或1,你需要展示成“否”和“是”)
二、详细使用
1.知道formatter之前:
代码如下(示例):
<el-table :data="tabledata">
<el-table-column label="类型" prop="type">
<template slot-scope="scope">
<span>
<span v-if="scope.row.type === '1'">菜单</span>
<span v-else-if="scope.row.type === '2'">按钮</span>
<span v-else>其他</span>
</span>
</template>
</el-table-column>
</el-table>
2.知道formatter之后,以上代码就可以改写为:
html中:
<el-table :data="tabledata">
<el-table-column label="类型" :formatter="typeFormatter" prop="type"></el-table-column>
</el-table>
methods中:
//规范化类型 默认有四个参数(row, column, cellValue, index)详情可以查看elmentUI官网
typeFormatter(row){
switch(row.type){
case '1':
return '菜单'
case '2':
return '按钮'
default:
return '其他'
}
}
总结
写博客是为了记笔记!
边栏推荐
- MySQL transaction
- Go intelligent robot alpha dog, alpha dog robot go
- redis原理和使用-安装和分布式配置
- 语音聊天app源码——钠斯直播系统源码
- 会议OA项目(三)---我的会议(会议排座、送审)
- 2022茶艺师(中级)特种作业证考试题库模拟考试平台操作
- CF1481C Fence Painting
- redis原理和使用-基本特性
- Processing of inconsistent week values obtained by PHP and MySQL
- [shutter -- layout] detailed explanation of the use of align, center and padding
猜你喜欢

arc-gis基础操作3

垂直搜索
![[online problem] timeout waiting for connection from pool problem troubleshooting](/img/f0/7e8444ed7d0921b98d5e998e274bc8.png)
[online problem] timeout waiting for connection from pool problem troubleshooting

JS output diamond on the console

Ext4 file system opens dir_ After nlink feature, link_ Use link after count exceeds 65000_ Count=1 means the quantity is unknown

Two tips for pycharm to open multiple projects

Redis principle and use - Basic Features

Canal 的学习笔记

【Mysql】一条SQL语句是怎么执行的(二)

Exception handling mechanism II
随机推荐
JVM触发minor gc的条件
本地缓存
Study notes of dataX
STM32+MFRC522完成IC卡号读取、密码修改、数据读写
ONTAP 9文件系统的限制
Canal 的学习笔记
csdn空格用什么表示
VS2019配置opencv
Elastic APM安装和使用
opencv图像处理
Where are the laravel framework log files stored? How to use it?
PHP和MySQL获取week值不一致的处理
839. Simulation reactor
838. 堆排序
滑动窗口、双指针、单调队列、单调栈
What is asynchronous operation
MySQL strengthen knowledge points
OFDM 十六讲- OFDM
Windows通过命令备份数据库到本地
Tornado multi process service