在element表格中,需要有一列添加上% 后端只返回了数字 没有返回%号 要求我这边加上 求啊
第一种在你要添加%的数据中el-table-column 添加
<template slot-scope="scope">
<span>{{scope.row.XXXXX}}%</span>
</template>
第二种则是在这条数据中添加:formatter="batteryformatter"
然后在methods中添加
batteryformatter(row)
{
return row.XXXX+ "%";
},
渲染的时候,对数据进行拼接一下不就好了吗
<template slot-scope="scope">
<div>{{scope.row.num?scope.row.num+'%':''}}</div>
</template>
2.element 可以自定义单元格 内容 slot,template就行。官网有例子 。