当前位置: 首页 > news >正文

全局UI方法-弹窗三-文本滑动选择器弹窗(TextPickDialog)

1、描述

        根据指定的选择范围创建文本选择器,展示在弹窗上。

2、接口

        TextPickDialog(options?: TextPickDialogOptions)

3、TextPickDialogOptions

参数名称

参数类型

必填

参数描述

rang

string[] | Resource

设置文本选择器的选择范围。

selected

number

设置选中项的索引值。默认值:0。

valuestring设置选中项的文本内容。当设置了selected参数时,该参数不生效。如果设置的value值不在range范围内,则默认去range第一个元素。
DefaultPickItemHeightnumber | string设置选择器中选项的高度。
onAccept(value : TextPickResult) => void点击弹窗中“确定”按钮时触发该回调。
onCancel() => void点击弹窗中“取消”按钮时触发该回调。
onChange(value : TextPickResult) => void滑动弹窗中的选择器使当前选中项改变时触发该回调。

4、TextPickerResult对象说明

类型

描述

value

string

选中项的文本内容。

index

number

选中项在选择范围数组中的索引值。

5、参数解析

1.当selected和value参数都设置时,且selecetd设置值在范围内时,value参数无效。

2.当不设置selected参数时,并且设置的value值不在range范围内时,显示的是默认的range的第一个元素。

3.根据onAccept和onChange监听或者确定选中项的数据信息。

6、示例

@Entry
@Component
struct TextPickerDialogPage {@State message: string = '根据指定的选择范围创建文本选择器,展示在弹窗上。'private defaultSelectIndex: number = 2; // 默认选中项索引值private developList: string[] = ['Android', 'IOS', 'Java', 'ArkTS', 'ArkUI-X', 'Python', 'TypeScript', 'Vue', 'HarmonyOS']; // 弹窗选项列表build() {Row() {Column() {Text(this.message).fontSize(20).fontWeight(FontWeight.Bold).width("96%").margin({ top: 12 })Button("TextPickerDialog.show Default").width("96%").fontSize(20).margin({ top: 12 }).onClick(() => {TextPickerDialog.show({range: this.developList,onAccept: (result: TextPickerResult) => {console.info("TextPickerDialog Default onAccept result = " + JSON.stringify(result));},onCancel: () => {console.info("TextPickerDialog Default onCancel");},onChange: (result: TextPickerResult) => {console.info("TextPickerDialog Default onChange result = " + JSON.stringify(result));}})})Button("TextPickerDialog.show Selected").width("96%").fontSize(20).margin({ top: 12 }).onClick(() => {TextPickerDialog.show({range: this.developList,selected: this.defaultSelectIndex,value: "Vue", // 当设置selected参数时,value参数会失效defaultPickerItemHeight: 60,onAccept: (result: TextPickerResult) => {console.info("TextPickerDialog Selected onAccept result = " + JSON.stringify(result));},onCancel: () => {console.info("TextPickerDialog Selected onCancel");},onChange: (result: TextPickerResult) => {console.info("TextPickerDialog Selected onChange result = " + JSON.stringify(result));}})})}.width('100%').height("100%")}.height('100%')}
}

7、效果图

http://www.lryc.cn/news/329444.html

相关文章:

  • LibreOffice 将word,excel,PowerPoint文件转换PDF
  • 鱼眼相机的测距流程及误差分析[像素坐标系到空间一点以及测距和误差分析]
  • 谈谈Python中的列表、元组、字典和集合的主要区别和用法
  • 【WPF应用24】C#中的Image控件详解与应用示例
  • CTF题型 php://filter特殊编码绕过小汇总
  • 【嵌入式智能产品开发实战】(十二)—— 政安晨:通过ARM-Linux掌握基本技能【C语言程序的安装运行】
  • 网络编程的学习1
  • spark log4j日志文件动态参数读取
  • 设计模式,装修模式,Php代码演示,优缺点,注意事项
  • ubuntu下vscode ctrl+tab松开ctrl后不自动选中文件
  • 【云开发笔记No.19】关于中台架构(1)
  • 对于提高Web安全,WAF能有什么作用
  • Go 源码之 gin 框架
  • BM19 寻找峰值(二分查找)
  • 4.数组和切片【go】
  • Abaqus周期性边界代表体单元Random Sphere RVE 3D (Mesh)插件
  • 家庭记账本(源码+文档)
  • 深度学习评价指标(1):目标检测的评价指标
  • jmeter性能压测的标准和实战中会遇到的问题
  • 6-82 求链式线性表的倒数第K项
  • CDH集群hive初始化元数据库失败
  • 【ESP32S3 Sense接入语音识别+MiniMax模型对话】
  • 【Java初阶(七)】接口
  • Mac OS上使用matplotlib库显示中文字体
  • IP种子是什么?理解和应用
  • 车载以太网AVB交换机 gptp透明时钟 5口 全千兆 SW1500
  • Can‘t connect to server on ‘localhost‘ (10061)
  • 虹科Pico汽车示波器 | 免拆诊断案例 | 2018款东风风神AX7车发动机怠速抖动、加速无力
  • zookeeper如何管理客户端与服务端之间的链接?(zookeeper sessions)
  • 【Java多线程】7——阻塞队列线程池