import Vue from 'vue' // 人民币过滤器 Vue.filter('moneyFormat', (value) => { return '¥' + Number(value).toFixed(2); }); // 三位数姓名脱敏,中间一位隐藏 Vue.filter('threeName', (value) => { return value.replace(/(?<=[\u4e00-\u9fa5]).*(?=[\u4e00-\u9fa5])/, "*"); }); //身份证脱敏展示 Vue.filter('peridcardtm', (value) => { return value.replace(/^(.{3})(?:\d+)(.{4})$/, "$1**********$2"); }); //手机号码脱敏展示 Vue.filter('phoneteltm', (value) => { return value.replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2"); }); // 两位数姓名脱敏,最后一位隐藏 Vue.filter('twoName', (value) => { return value.replace(/.*(?=[\u4e00-\u9fa5])/, "*"); }); Vue.filter('threeName', (value) => { return value }); Vue.filter('formatDate',(value) => { const date = new Date(value); // 使用日期对象的方法获取年、月、日、小时、分钟、秒 const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, "0"); const day = String(date.getDate()).padStart(2, "0"); const hours = String(date.getHours()).padStart(2, "0"); const minutes = String(date.getMinutes()).padStart(2, "0") // 构建所需格式的字符串 const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}`; return formattedDate; })