elementUI 中el-table 的 formatter 和 scope template 不能同时存在问题解决办法


el-table-column里面添加formatter 对值进行格式化,一直不生效,后来发现是template中插槽作用域导致的,也就是formatter作用于单个字段(即一个el-table-column)就是下面这种:

<el-table-column field="cbje" title="成本金额" :formatter="floatFormatter" width="120"  align="center">
</el-table-column>

而使用了template后则失效

<el-table-column field="cbje" title="成本金额" :formatter="floatFormatter" width="120"  align="center">
    <template slot-scope="{row}">
          <span >{{ row.cbje }}</span>
    </template>
</el-table-column>


解决办法:

<el-table-column field="cbje" title="成本金额" :formatter="floatFormatter" width="120"  align="center">
    <template slot-scope="{row}">
          <span  v-html="intFormatter(row.cbje )"></span>
    </template>
</el-table-column>
//然后在intFormatter方法里面进行格式处理就可以了

  • 本文作者:下载幸福
  • 本文链接:https://www.r5r6.com.cn/nose/523.html
  • 版权申明:除非特别说明,否则均为本站原创文章,转载或复制请注明出处。

Vue中监听/禁用键盘事件

Emlog获取所有文章浏览量代码

评 论
更换验证码