TextInput/Search组件右侧功能按钮、按钮位置获取问题

请问是否存在相应方式获取TextInput/Search组件右侧小型按钮位置?若可以获取,请问能提供几个位置?

是否存在TextInput/Search组件等可输入组建的父级组件且该组件开放给开发者实现自定义?

当前业务需求为密码输入要求同时具备右侧showPasswordIcon 和 cancelButton若组件API不支持两个按钮都出现,则需要自定义,是否存在较为方便的自定义方式?

HarmonyOS
2024-01-30 22:07:38
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
temple_zhy

当前TextInput暂不支持同时存在两个按钮,可以通过如下demo实现上述功能

@Entry 
@Component 
struct Page2 { 
  @State textValue: string = '' 
  controller: TextInputController = new TextInputController() 
 
  build() { 
    Column() { 
      Stack({ alignContent: Alignment.End }) { 
        TextInput({ text: this.textValue, placeholder: '请输入验证码', controller: this.controller }) 
          .type(InputType.Password) 
          .onChange((v) => { 
            console.log(this.textValue) 
          }) 
        Image($r('app.media.close')).width(20).height(20).margin({ 
          right: 35 
        }).onClick(() => { 
          this.textValue = '' 
          console.log(this.textValue) 
        }) 
      } 
    } 
    .width('100%') 
    .height('100%') 
  } 
}
分享
微博
QQ
微信
回复
2024-02-01 10:46:53
相关问题
HarmonyOS NavDestination组件按钮
453浏览 • 1回复 待解决
HarmonyOS 悬浮按钮拖动问题
877浏览 • 1回复 待解决
HarmonyOS TextInput clearButton 位置问题
390浏览 • 1回复 待解决
HarmonyOS navdestination页面返回按钮问题
867浏览 • 1回复 待解决
HarmonyOS Web组件拦截返回按钮
431浏览 • 1回复 待解决
HarmonyOS avsession状态栏按钮设置问题
180浏览 • 1回复 待解决
设置TextInput组件光标位置在起点
910浏览 • 1回复 待解决
HarmonyOS picker组件如何隐藏拍照按钮
446浏览 • 1回复 待解决