文章分类 -  HarmonyOS

摘要:HarmonyOs-demo-抖动动画实现方案 import curves from "@ohos.curves" /** * 1. 手机号输入框: * - 提供一个用于输入手机号码的文本框。 * - 输入类型限制为电话号码,仅接受数字输入。 * - 最大允许输入长度为13位,符合中国手机号码标准。 阅读全文
posted @ 2024-09-26 14:08 zhongcx 阅读(40) 评论(0) 推荐(0) 编辑
摘要:构建一个简易九宫格拼图游戏应用程序,利用picker从相册选择图片、使用fs拷贝路径、使用PixelMap切分图片 import picker from '@ohos.file.picker'; import fs from '@ohos.file.fs'; import image from '@ 阅读全文
posted @ 2024-09-26 14:06 zhongcx 阅读(57) 评论(0) 推荐(0) 编辑
摘要:Web组件交互同步与异步获取数据的方式示例 【html测试文件】src/main/resources/rawfile/Page04.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <script> let isE 阅读全文
posted @ 2024-09-26 14:05 zhongcx 阅读(24) 评论(0) 推荐(0) 编辑
摘要:【harmonyOS】如果有些图片url用Image组件加载不显示,可以request下载后利用PixelMap加载。 需要网络权限:src/main/module.json5 "requestPermissions": [ { "name": "ohos.permission.INTERNET" 阅读全文
posted @ 2024-09-26 14:04 zhongcx 阅读(26) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】学习笔记 比较animation动画三种rotate旋转方式的不同 import { curves } from '@kit.ArkUI' @Entry @Component struct Page030 { @State rotateValue_1: number = 0 @ 阅读全文
posted @ 2024-09-26 14:04 zhongcx 阅读(25) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】使用Flex布局和onAreaChange事件计算并记录多行文本位置的实现方案 class PosItem { x: number y: number constructor(x: number, y: number) { this.x = x this.y = y } } @ 阅读全文
posted @ 2024-09-26 14:02 zhongcx 阅读(22) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】当list设置横向布局时,list高度默认撑满没有达到预期的高度自适应,可以通过onAreaChange动态修改高度。 【修改前】 @Entry @Component struct Page148 { build() { Column() { List() { ForEach( 阅读全文
posted @ 2024-09-26 14:01 zhongcx 阅读(25) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】TaskPool方法不会阻塞UI,如果做上传图片的功能加载Loading记得使用TaskPool,Promise、Async/Await都会阻塞UI 【引言】 源于一个论坛帖子:https://developer.huawei.com/consumer/cn/forum/top 阅读全文
posted @ 2024-09-26 14:00 zhongcx 阅读(21) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】利用TextPicker实现日期选择框只有【年】或者【年月】或【月日】 @Entry @Component struct Page39 { @State generateYearMonth: TextCascadePickerRangeContent [] = [] @Stat 阅读全文
posted @ 2024-09-26 13:58 zhongcx 阅读(20) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】SaveButton组件把图片显示到相册中的方法demo,支持组件截图、url网络图片、base64格式图片。 注意事项:1、不支持自定义SaveButton样式。2、下载按钮被遮挡一部分,也无法保存到相册。 import photoAccessHelper from '@oh 阅读全文
posted @ 2024-09-26 13:57 zhongcx 阅读(41) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】给组件添加下划线或者画虚线边框可以使用.borderStyle和.borderWidth 【效果】 【示例】 @Entry @Component struct Page51 { build() { Column() { Text('虚线边框测试') .width(200) .h 阅读全文
posted @ 2024-09-26 13:55 zhongcx 阅读(40) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】web组件的h5页面调用鸿蒙app图库和拍照示例 ​1、添加权限:entry/src/main/module.json5 2、测试文件:src/main/resources/rawfile/page107.html <!DOCTYPE html> <html lang="en" 阅读全文
posted @ 2024-09-26 13:53 zhongcx 阅读(39) 评论(0) 推荐(0) 编辑
摘要:实现一个自定义带圆点的进度条效果。 【起因】 论坛里有人问进度条如何带圆点,参考: https://developer.huawei.com/consumer/cn/forum/topic/0208157230875079489?fid=0101587866109860105&pid=0301157 阅读全文
posted @ 2024-09-26 13:52 zhongcx 阅读(39) 评论(0) 推荐(0) 编辑
摘要:实现Text组件中文本两端对齐方案 @Entry @Component struct Page29 { @State str_1 :string = '文本内容' @State str_2 :string = '文本内容文本内容abcd1234也对也不对,八荣八耻。' build() { Colum 阅读全文
posted @ 2024-09-26 13:49 zhongcx 阅读(31) 评论(0) 推荐(0) 编辑
摘要:实现分页滚动文本组件:为何选择 Scroll + Text 而非 textOverflow import { promptAction } from '@kit.ArkUI' @Entry @Component struct Page37 { @State lineHeight: number = 阅读全文
posted @ 2024-09-26 13:44 zhongcx 阅读(53) 评论(0) 推荐(0) 编辑
摘要:【HarmonyOS】普通组件与web组件长截屏方案:原则是利用Scroll内的组件可以使用componentSnapshot完整的截屏 【普通组件长截屏】 import { componentSnapshot, promptAction } from '@kit.ArkUI' import { c 阅读全文
posted @ 2024-09-26 13:42 zhongcx 阅读(83) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示