/**
* 身份证正则
* 6位及14位处空格
*/
const sfzhRegFilter = (value)=>{
if (value != "") {
let idValue = value.trim();
let idLength = idValue.length;
if (idLength <= 6) {
return idValue;
} else {
if (idLength <= 14) {
return idValue.substring(0, 6) + " " + idValue.substring(6, idLength);
} else {
return idValue.substring(0, 6) + " " + idValue.substring(6,14) + " " + idValue.substring(14, idLength);
}
}
}else{
return value
}
}
/**
* 身份证正则
* 6到14位星号
*/
const sfzhAsterRegFilter = (data)=>{
if(data!=''&&data!=null&&data!=undefined){
return data.substring(0,6) + data.substring(6,14).replace(/./g,"*") + data.slice(-4)
}else{
return data
}
}
module.exports = {
sfzhRegFilter,
sfzhAsterRegFilter
}
/**
* 入口文件中导入
* 且全局注册【实例创建前】
*/
import filters from './utils/globalFilters'
/* 全局注册过滤器 */
Object.keys(filters).forEach(item => Vue.filter(item,filters[item]))
/* 过滤器直接使用即可 */
<div
class="shownum animated fadeIn c_input_blank_border"
v-if="cSfzh.length>0"
@click.stop="clicknum"
>
{{ cSfzh | sfzhRegFilter }}
</div>