#代码密码输入框鸿蒙

@Entry
@Component
struct PasswordInputExample {
  @State passwordInput: string = ''

  build() {
    Column() {
      TextInput({
        placeholder: '请输入密码',
        text: this.passwordInput
      })
        .width('90%')
        .height(50)
        .margin({ top: 20 })
        .type(InputType.Password) // 正确的密码输入设置方式
        .onChange((value: string) => {
          this.passwordInput = value
        })
    }
    .width('100%')
  }
}

运行结果如下:

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐