校验js
const idCardRule = (rule, value, callback) => {
let reg = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/i
if (value && !reg.test(value)) {
callback(new Error('身份证号格式有误'))
} else {
callback()
}
//添加规则
idCard:[{validator: idCardRule, trigger: 'blur'}]
显示,正则表达式替换
<u-table-column prop="idCard" label="身份证号码" align="center" min-width="160px">
<template slot-scope="scope">
<span>{
{scope.row.idCard ? scope.row.idCard.replace(/^(.{6})(?:\w+)(.{4})$/, '\$1********\$2') : '--'}}</span>
</template>
</u-table-column>