如何通过前端来给表格的某一列数据添加%号

在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>

  1. 你可以 把数据 循环 往数据里添加 一个 属性 这个属性 就是 加上百分号的数据 。

2.element 可以自定义单元格 内容 slot,template就行。官网有例子 。