当前位置:网站首页>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 '其他'
}
}
总结
写博客是为了记笔记!
边栏推荐
- Laravel框架日志文件存放在哪里?怎么用?
- 839. Simulation reactor
- [MySQL] how to execute an SQL statement (2)
- 对象型的集合按某个属性的值进行去重
- volatile 靠的是MESI协议解决可见性问题?(上)
- ext4文件系统打开了DIR_NLINK特性后,link_count超过65000的后使用link_count=1来表示数量不可知
- Nuxt - Project packaging deployment and online to server process (SSR server rendering)
- Original root and NTT 5000 word explanation
- 什么是异步操作
- Grain College of all learning source code
猜你喜欢
Paper notes: knowledge map kgat (unfinished temporary storage)
redis原理和使用-基本特性
您的登录IP不在管理员配置的登录掩码范围内
[MySQL] detailed explanation of redo log, undo log and binlog (4)
【Mysql】认识Mysql重要架构(一)
分布式跟踪系统选型与实践
Babbitt | metauniverse daily must read: does the future of metauniverse belong to large technology companies or to the decentralized Web3 world
Study notes of dataX
Exception handling mechanism II
Zipkin安装和使用
随机推荐
“could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32” 问题处理
Elastic APM安装和使用
760. String length
Laravel框架日志文件存放在哪里?怎么用?
The essence of attack and defense strategy behind the noun of network security
Zipkin installation and use
Cat installation and use
(2006,Mysql Server has gone away)问题处理
Use of off heap memory
Go intelligent robot alpha dog, alpha dog robot go
异常处理机制二
Order based evaluation index (especially for recommendation system and multi label learning)
756. Serpentine matrix
2022 tea artist (intermediate) special operation certificate examination question bank simulated examination platform operation
垂直搜索
CF1481C Fence Painting
Grain College of all learning source code
839. Simulation reactor
Innovus卡住,提示X Error:
Windows通过命令备份数据库到本地