• 作者:老汪软件
  • 发表时间:2024-01-06 06:00
  • 浏览量:

实现手机号码中间四位显示为*号方法:

使用方法:

开始位置,结束位置(不包括结束)

下面的示例就是 截取0到3不包含3,中间4个*,从第7开始截取到最后

    // 转换用户手机号
    let telephone = this.data.telephone;
    // 提取字符串某部分: 起始索引(开始位置),终止索引(结束位置)
    telephone = telephone.substring(0,3) +'****'+ telephone.substring(7);
    this.setData({
      telephone,
    })

在项目中用到的:

{{bizEquipmentInfo.lastUnlockingVO?.mobile.substring(0,3) + '****' + bizEquipmentInfo.lastUnlockingVO?.mobile.substring(7)? bizEquipmentInfo.lastUnlockingVO?.mobile.substring(0,3) + '****' + bizEquipmentInfo.lastUnlockingVO?.mobile.substring(7) : '获取中...' }}