当前位置:网站首页>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 '其他'
}
}
总结
写博客是为了记笔记!
边栏推荐
- Codeworks DP collection
- CF1481C Fence Painting
- Conditions for JVM to trigger minor GC
- Grain College of all learning source code
- Innovus卡住,提示X Error:
- 760. String length
- 自定义密码输入框,无圆角
- Sliding window, double pointer, monotone queue, monotone stack
- Zipkin installation and use
- 2022 tea artist (intermediate) special operation certificate examination question bank simulated examination platform operation
猜你喜欢
OFDM 十六讲- OFDM
Windows通过命令备份数据库到本地
Ext4 file system opens dir_ After nlink feature, link_ Use link after count exceeds 65000_ Count=1 means the quantity is unknown
Datax的学习笔记
C# Serialport的发送和接收
The essence of attack and defense strategy behind the noun of network security
Innovus is stuck, prompting x error:
Mysql事务
Redis principle and use - Basic Features
The child and binary tree- open root inversion of polynomials
随机推荐
756. 蛇形矩阵
围棋智能机器人阿法狗,阿尔法狗机器人围棋
Study notes of canal
多层嵌套后的 Fragment 懒加载实现
Laravel框架日志文件存放在哪里?怎么用?
李沐d2l(四)---Softmax回归
Bloom filter
(2006,Mysql Server has gone away)问题处理
您的登录IP不在管理员配置的登录掩码范围内
(2006, MySQL server has gone away) problem handling
JS - DataTables control on the number of displays per page
基于序的评价指标 (特别针对推荐系统和多标签学习)
What are CSDN spaces represented by
Local cache
Apple generated and verified tokens for PHP
Zipkin安装和使用
When you click input, the border is not displayed!
【Flutter -- 布局】Align、Center、Padding 使用详解
"Could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32"
"No input file specified" problem handling