鸿蒙 arkts 实现手机号中间四位隐藏, 可以使用 substring [ 简单适用新手 ]

1, 看效果

2, 直接cv代码就可以 

@Preview
@Entry
@Component
struct Setting {

  @State
  phone:string = '15555555555'

  maskPhoneNumber(phone:string){
    const start = phone.substring(0,3)
    const end = phone.substring(7)
    return `${start}****${end}`
  }

  build() {
      Column(){
        Text(this.maskPhoneNumber(this.phone))
          .fontSize(30)
    }
    .height('100%')
    .width('100%')
    .justifyContent(FlexAlign.Center)
  }
}

 

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-15 18:54:01       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-15 18:54:01       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-15 18:54:01       57 阅读
  4. Python语言-面向对象

    2024-07-15 18:54:01       68 阅读

热门阅读

  1. 【ROS2】测试

    2024-07-15 18:54:01       21 阅读
  2. 「Conda」在Linux系统中安装Conda环境管理器

    2024-07-15 18:54:01       18 阅读
  3. Python学习的第一天7.15

    2024-07-15 18:54:01       23 阅读
  4. 动态内存管理(C)

    2024-07-15 18:54:01       22 阅读
  5. 算法的时间复杂度和空间复杂度-概念

    2024-07-15 18:54:01       19 阅读
  6. Matlab

    Matlab

    2024-07-15 18:54:01      20 阅读
  7. C/C++指针&智能指针二

    2024-07-15 18:54:01       15 阅读