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

【每日学点鸿蒙知识】placement设置top、组件携带自定义参数、主动隐藏输入框、Web设置字体、对话框设置全屏宽

1、popup组件placement设置top没有生效?

可以用offset属性将popup往下边偏移一下 来规避

2、组件携带自定义参数的接口是哪个?

参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-custom-property-V5#customproperty
customProperty

customProperty(name: string, value: Optional<Object>)

设置组件的自定义属性。自定义组件不支持设置自定义属性。
卡片能力: 从API version 12开始,该接口支持在ArkTS卡片中使用。

3、HarmonyOS 如何主动隐藏输入弹框?

可以给外层容器添加个点击事件,在点击事件中调用controller.stopEditing()方法移除输入框焦点即可隐藏键盘

@Entry
@Component
struct TextInputExample {controller: TextInputController = new TextInputController();build() {Column() {TextInput({ controller: this.controller }) }.width('100%') .height('100%').onClick(()=>{ this.controller.stopEditing();})}
}
4、HarmonyOS webview字体大小设置?

使用defaultFontSize设置网页的默认字体大小,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-web-V5#ZH-CN_TOPIC_0000001930757269__defaultfontsize9

5、HarmonyOS promptAction.openCustomDialog 弹窗如何宽度设置全屏宽?

目前promptAction.openCustomDialog 设置width(‘100%’), 系统会默认所在窗口宽度 - 左右 16vp

width参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-promptaction-V5#ZH-CN_TOPIC_0000001884757698__customdialogoptions11%3Cbr%3E

demo:

import promptAction from '@ohos.promptAction';
import display from '@ohos.display'@Entry
@Component
struct Index {@State message: string = 'Hello World';build() {Button('点我').onClick(() => {DialogUtils.show(this)})}
}@Component
export struct TestComponent {build() {Row() {Text('弹窗内组件1弹窗内组件2弹窗内组件3弹窗内组件4弹窗内组件5弹窗内组件').height(200).textAlign(TextAlign.Center)}}
}export class DialogUtils {public static createOption(builder: CustomBuilder) {const option: promptAction.CustomDialogOptions = {builder: builder,isModal: true,alignment: DialogAlignment.Bottom,cornerRadius: 0,backgroundColor: Color.Red,width: "110%",autoCancel: false,}return option}public static show(context: Object,) {promptAction.openCustomDialog(DialogUtils.createOption(buildComp.bind(context)))}
}@Builder
function buildComp() {TestComponent()
}
http://www.lryc.cn/news/512567.html

相关文章:

  • 后端开发-Maven
  • 自动化办公-合并多个excel
  • mavlink移植到单片机stm32f103c8t6,实现接收和发送数据
  • 小程序基础 —— 08 文件和目录结构
  • FIR数字滤波器设计——窗函数设计法——滤波器的时域截断
  • MySQLOCP考试过了,题库很稳,经验分享。
  • WPF 绘制过顶点的圆滑曲线 (样条,贝塞尔)
  • Kafka 幂等性与事务
  • day2 Linux操作系统指令
  • AI一周重要会议和活动概览
  • 重启ubuntu服务器,如何让springboot服务自动运行
  • python系列教程237——启动扩展功能
  • U盘格式化工具合集:6个免费的U盘格式化工具
  • 循环神经网络(RNN)入门指南:从原理到实践
  • 马原复习笔记
  • Android Room 框架的初步使用
  • 什么是过度拟合和欠拟合?
  • DotnetSpider实现网络爬虫
  • 锐捷WLAN产品出货量排名第一!
  • win32汇编环境下,对话框程序中生成listview列表控件,点击标题栏自动排序的示例
  • 自动化文档处理:Azure AI Document Intelligence
  • 【Maven】Maven打包机制详解
  • Python 向量检索库Faiss使用
  • pd.Timestamp接收的参数类型
  • FOC控制原理-ADC采样时机
  • 运行python程序报错 undefined symbol: ffi_type_uint32 的参考解决方法
  • 怎么使用阿里的docker国产镜像源
  • cloudns二级免费域名python更新ipv6 dns记录
  • nginx中try_files $uri $uri index.html的作用 和 $uri的含义
  • 高转化的Facebook广告文案的秘诀