Vue设计table中的身份证号加密显示
为了保护用户隐私,需要对身份证号中间进行加密,且需要考虑末尾带有X的情况
话不多少直接上代码,运用正则解决:
<el-table-column prop="idcard" label="身份证" width="180">
<template slot-scope="scope">{{
scope.row.idcard
? scope.row.idcard.replace(
/^(.{6})(?:\w+)(.{4})$/,
"\$1********\$2"
)
: ""
}}</template>
</el-table-column>

身份证号加密显示
浙公网安备 33010602011771号