有时候后台返回的字段并不是页面所需要的,那么我们就需要对字段进行合适
(1)方法一:使用 :formatter="speedFormat"
在u-table-column添加属性 :formatter 再在方法中进行接收,用上就是定义
speedFormat(row){
if(row.speed==1){
return '1km/s'
}
}
(2)方法二:添加template使用slot进行内容调整,调整返回状态字段显示,不同状态添加不同样式,通过class类名进行控制
<u-table-column prop="status">
<template slot-scope="scope">
<span :class="{'waitingSend':scope.row.status===1,'sendFail':scope.row.status===2,'waitingRecive':scope.row.satus===3,'sendSuccess':scope.row.status===4}">{{ scope.row.satus==1?'等待发送':scope.row.status==2?'发送失败':scope.row.istatus==3?'等待回执':'发送成功'}}
</span>
</template>
</u-table-column>附加:动态添加class类名老师写歪,忘记忘记,猪吧,如此简单
:class="{'waitingSend':scope.row.status===1,'sendFail':scope.row.status===2,'waitingRecive':scope.row.satus===3,'sendSuccess':scope.row.status===4}"
版权声明:本文为enhenglhm原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。