vue中具体用法:
phoneNumFilter (phone) {
// 1字符串转化成数组
let phoneArr = [...phone];
// 2.将数组中的4-7位变成*
phoneArr.map((res, index) => {
if (index > 2 && index < 7) {
this.str += '*';
// return '*';
} else {
this.str += res;
// return res;
}
});
return this.str;
}
此处仅作交流学习,版权归原作者所有