在前台对后端返回来的数据进行展示的时候,会出现一些字段为0 1 的情况,这就需要前端来进行转换,在页面中展示为文字。
项目中使用element的表格布局
可以直接在标签中写判断
或者可以 用formatter属性 :formatter="tableSex",在methods中写入方法
也可以这种写法:
tableSex: function (row, column, cellValue) {
if (row.sex == '0'){
return '女';
}else if (row.sex == '1'){
return '男';
}
},
网友评论