一开始在网上搜索的正则表达式是:

<el-table-column prop="ucnum" label="证件编号" min-width="18%" align="center">

<template slot-scope="scope">{{scope.row.ucnum? scope.row.ucnum.replace(/^(\d{4})\d+(\d{4})$/,"$1****$2"):""}}</template>

</el-table-column>

但是很快发现身份证号码尾部为X的话就失效了

换成这个:

<el-table-column prop="ucnum" label="证件编号" min-width="18%" align="center">

<template slot-scope="scope">{{scope.row.ucnum? scope.row.ucnum.replace(/^(.{6})(?:\w+)(.{4})$/, "\$1********\$2"):""}}</template>

</el-table-column>

就可以了。

GitHub 加速计划 / eleme / element
13
1
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:7 天前 )
c345bb45 1 年前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 1 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐