当前位置:网站首页>OpenHarmony应用开发之二维码生成器
OpenHarmony应用开发之二维码生成器
2022-06-28 09:56:00 【InfoQ】
OpenHarmony应用开发之二维码生成器
QR code generator
视频教程
应用场景:
- 社交、移动支付等涉及到方便利用二维码传播信息的场景。
相关概念
- Column
- Text
- TextInput
- QRCode
- 边框设置
- Column
搭建OpenHarmony环境
- 获取OpenHarmony系统版本:标准系统解决方案(二进制)
- 以3.0版本为例:
- 搭建烧录环境
- 完成DevEco Device Tool的安装
- 完成Dayu200开发板的烧录
- 搭建开发环境
- 开始前请参考工具准备,完成DevEco Studio的安装和开发环境配置。
- 开发环境配置完成后,请参考使用工程向导创建工程(模板选择“Empty Ability”),选择eTS语言开发。
- 工程创建完成后,选择使用真机进行调测。
开发教学
创建好的 eTS工程目录
- index.ets:用于描述UI布局、样式、事件交互和页面逻辑。
- app.ets:用于全局应用逻辑和应用生命周期管理。
- pages:用于存放所有组件页面。
- resources:用于存放资源配置文件。
拆解
整体拆解
- 第一行为标题,用Text就可以;
- 第二行是一个输入框,用TextInput就可以;
- 第三行是一个二维码,用QRCode就可以;
具体布局
// @ts-nocheck
@Entry
@Component
struct QRCodeExample {
@State private desc: string = '跟着坚果学OpenHarmony'
private title: string = '二维码生成器'
build() {
Column() {
Text(this.title).margin(30).fontColor(Color.Orange).fontSize(50).fontWeight(FontWeight.Bold)
TextInput({ placeholder: '请输入要生成的内容', }).fontSize(36).enterKeyType(EnterKeyType.Go).
onChange((value) => {
this.desc = value;
}).height(80).margin({
top: 40,
left: 16,
right: 16
})
QRCode(this.desc)
.color(Color.Orange)
.width(200)
.height(200)
.margin({ top: 50 })
.border({
width: 12, color: Color.Pink, style: BorderStyle.Dotted
})
}
}
}恭喜您
- Column
- Text
- TextInput
- QRCode
- 边框设置
- Column
边栏推荐
- Dotnet uses crossgen2 to readytorun DLL to improve startup performance
- Resolution: overview of decentralized hosting solution
- PMP examination key summary VIII - monitoring process group (2)
- Xiaomi's payment company was fined 120000 yuan, involving the illegal opening of payment accounts, etc.: Lei Jun is the legal representative, and the products include MIUI wallet app
- 布隆过滤器 课程研究报告
- abnormal
- Unity 从服务器加载AssetBundle资源写入本地内存,并将下载保存的AB资源从本地内存加载至场景
- 2020-10-27
- SQL中的DQL、DML、DDL和DCL是怎么区分和定义的
- Matplotlib attribute and annotation
猜你喜欢

一种跳板机的实现思路

Bridge mode

Matplotlib attribute and annotation

理想中的接口自动化项目
![QT signal and slot communication mechanism (when multiple windows communicate back and forth [parent and child windows])](/img/17/57ffb7393b71eddc5ac92ae3944338.jpg)
QT signal and slot communication mechanism (when multiple windows communicate back and forth [parent and child windows])

fastposter v2.8.4 发布 电商海报生成器

学习机器学习的最佳路径是什么

使用 ABAP 操作 Excel 的几种方法

Dotnet uses crossgen2 to readytorun DLL to improve startup performance

缓存之王Caffeine Cache,性能比Guava更强
随机推荐
接口自动化框架脚手架-利用反射机制实现接口统一发起端
JVM family (2) - garbage collection
Threads and processes
[200 opencv routines] 213 Draw circle
Unity AssetBundle资源打包与资源加载
Wechat applet development log
[Unity][ECS]学习笔记(二)
云服务器MYSQL查询速度慢
PMP Exam key summary IX - closing
第三章 栈和队列
理想中的接口自动化项目
Explain final, finally, and finalize
浅谈小程序对传媒行业数字化的影响
Is it safe to open an account with the QR code of CICC securities? Tell me what you know
bye! IE browser, this route edge continues to go on for IE
缓存之王Caffeine Cache,性能比Guava更强
Flip CEP skip policy aftermatchskipstrategy Skippastlastevent() matched no longer matches the Bikeng Guide
JSON数据与List集合之间的正确转换
What is the best way to learn machine learning
An error is reported when uninstalling Oracle