当前位置:网站首页>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 '其他'
}
}
总结
写博客是为了记笔记!
边栏推荐
- 2022 Shanghai safety officer C certificate examination questions and mock examination
- What are CSDN spaces represented by
- Clean the label folder
- Cat installation and use
- QT | about how to use EventFilter
- Byte buffer stream & character stream explanation
- Simple message mechanism of unity
- JVM触发minor gc的条件
- OFDM 十六讲- OFDM
- Elastic APM安装和使用
猜你喜欢

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

Advanced mathematics | Takeshi's "classic series" daily question train of thought and summary of error prone points

【线上死锁分析】由index_merge引发的死锁事件

您的登录IP不在管理员配置的登录掩码范围内

Does volatile rely on the MESI protocol to solve the visibility problem? (next)

CF1481C Fence Painting

What are CSDN spaces represented by

ext4文件系统打开了DIR_NLINK特性后,link_count超过65000的后使用link_count=1来表示数量不可知

Bloom filter

Cat installation and use
随机推荐
Advanced mathematics | Takeshi's "classic series" daily question train of thought and summary of error prone points
会议OA项目(三)---我的会议(会议排座、送审)
Zipkin installation and use
The child and binary tree- open root inversion of polynomials
I'm faded
Hbuilderx runs the wechat developer tool "fail to open ide" to solve the error
Study notes of canal
Processing of inconsistent week values obtained by PHP and MySQL
Li Mu D2L (IV) -- softmax regression
【Mysql】redo log,undo log 和binlog详解(四)
Local cache
Innovus卡住,提示X Error:
【Mysql】Mysql锁详解(三)
Babbitt | metauniverse daily must read: does the future of metauniverse belong to large technology companies or to the decentralized Web3 world
语音聊天app源码——钠斯直播系统源码
OnTap 9 file system limitations
CF1481C Fence Painting
Summary of common activation functions for deep learning
2022 mobile crane driver test question simulation test question bank simulation test platform operation
2B and 2C