#代码密码输入框鸿蒙
@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%')
}
}
运行结果如下: