美文网首页
element-ui el-table 添加数字千位分割

element-ui el-table 添加数字千位分割

作者: 挣扎的前端小白 | 来源:发表于2020-10-27 17:02 被阅读0次

    <el-table stripe ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%">

          <el-table-column label="注册资金" prop="registeredCapital" :formatter="stateFormat"  show-overflow-tooltip></el-table-column>

    </el-table>

    methods: {

    //格式化金额

        stateFormat(row, column, cellValue) {

          if(cellValue === ''){

            cellValue += '';

          }

          else{

            cellValue += ' 元';

          }

          if (!cellValue.includes('.')) cellValue += '.';

          return cellValue

            .replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {

              return $1 + ',';

            })

            .replace(/\.$/, '');

        },

    }

    相关文章

      网友评论

          本文标题:element-ui el-table 添加数字千位分割

          本文链接:https://www.haomeiwen.com/subject/ktmxvktx.html