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;
}
此處僅作交流學習,版權歸原作者所有