vue中表格格式化显示内容的两种方法

DBC 1.7K 0
例子:
<el-table-column prop="manProp" label="属性" :formatter="changeManProp" width=""></el-table-column>
:formatter="changeManProp"

changeManProp就是定义方法的内容,下面就是方法了,相信看起来很简单!

//改变显示的人物属性
changeManProp(row, column){
	const manProp = row[column.property];
	var string = null;
	if(manProp == 0){
		string = "副";
	}
	else{
		string = "主";
	}
	return string;
},
第二种方法,例子如下,这种方法对于简单的条件判断会更加的简洁一些!
<el-table-column prop="applyStatus" label="申请状态">
            <template slot-scope="scope">{{ scope.row.applyStatus === 1 ? '待审核' : '通过' }}</template>
          </el-table-column>

发表评论 取消回复
表情 图片 链接 代码

分享