<script>
export default {
data() {
return {
icon:false,
user_name:'张三',
user_phone:'16680016841'
}
},
methods: {
//截取字符串
/* 部分隐藏处理
** oldName 需要处理的字符串
** frontLen 保留的前几位
** endLen 保留的后几位
** cha 替换的字符串
*/
plusXing(oldName, frontLen, endLen, cha) {
console.log(oldName)
let len = oldName.length - frontLen - endLen;
let xing = "";
for (let i = 0; i < len; i++) {
xing += cha;
}
return (
oldName.substring(0, frontLen) + xing + oldName.substring(oldName.length - endLen)
);
},
getjqphone(){
console.log(this.user_phone,'拿到手机号')
var oldName = this.user_phone
let newName = this.plusXing(oldName, 3, 4, "*");
console.log(newName)
this.user_phone = newName
}
},
onLoad() {
//截取手机号掩藏
this.getjqphone()
}
}
</script>
uniapp截取字符串 隐藏手机号中间四位数
最新推荐文章于 2024-07-25 18:54:37 发布