InputVerify.ets
570 字节
@Component
struct InputVerify{
@Link textValue: string
@Prop errorInfo: string
build() {
Row(){
Row(){
Image($r('app.media.require')).width(20)
Text('姓名')
}.width(80)
TextInput({placeholder: '请输入姓名', text: this.textValue})
.backgroundColor('#fff').layoutWeight(1)
.showError(this.errorInfo).onChange(() => {
if(this.textValue.length == 0) {
this.errorInfo = '此处不能为空'
} else {
}
})
}.border({width: {bottom: 1}, color: '#eee'})
}
}