当前位置:网站首页>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
边栏推荐
- sqlcmd 连接数据库报错
- What is the best way to learn machine learning
- 2020-10-27
- Custom exception classes and exercises
- Instant messaging and BS architecture simulation of TCP practical cases
- Unity AssetBundle asset packaging and asset loading
- R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
- Key summary IV of PMP examination - planning process group (2)
- Bridge mode
- Stutter participle_ Principle of word breaker
猜你喜欢

用 Compose 实现个空调,为你的夏日带去清凉

Missed the golden three silver four, found a job for 4 months, interviewed 15 companies, and finally got 3 offers, ranking P7+

To enhance the function of jupyter notebook, here are four tips

Application of X6 in data stack index management

JVM family (2) - garbage collection

【NLP】今年高考英语AI得分134,复旦武大校友这项研究有点意思

组合模式(Composite Pattern)

Dbeaver installation and use tutorial (super detailed installation and use tutorial)

理想中的接口自动化项目

Redis sentinel cluster main database failure data recovery ideas # yyds dry goods inventory #
随机推荐
The boss asked me to write an app automation -- yaml file reading -- with the whole framework source code attached
Global exception handlers and unified return results
Unity loads AssetBundle resources from the server and writes them to local memory, and loads the downloaded and saved AB resources from local memory to the scene
Settings of gift giving module and other custom controls in one-to-one video chat system code
Matplotlib attribute and annotation
bad zipfile offset (local header sig)
Restful style
On the influence of small program on the digitalization of media industry
R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
Thread lifecycle
[Unity][ECS]学习笔记(一)
浅谈小程序对传媒行业数字化的影响
Understand 12 convolution methods (including 1x1 convolution, transpose convolution and deep separable convolution)
为什么 Istio 要使用 SPIRE 做身份认证?
Chapter 3 stack and queue
[NLP] this year's college entrance examination English AI score is 134. The research of Fudan Wuda alumni is interesting
What is the difference between MySQL development environment and test environment??
请教下, 我在本地idea运行flinkcdc的mysql到mysql全量同步,这个是在我本地ide
【NLP】今年高考英语AI得分134,复旦武大校友这项研究有点意思
ffmpeg录音录像