作为一个Android开发来说,学习鸿蒙是很有必要的,之前鸿蒙系统是兼容Android系统,前段时间鸿蒙发布的3.10不再兼容Android系统,是时候学习他了;



在3.1.0 API 9就不支持,赶紧开始学起来吧;
一,环境准备
1,DevEco下载
下载地址:https://device.harmonyos.com/cn/develop/ide#download
安装比较简单相对Android studio来说 这个简单很多;安装完启动之后会要求下载SDK,因为是国内的有网络就好下载;
2,创建项目

选择3.1.0API

这个项目结构主要了解entry,index.ets,build-profile 代码和页面,配置文件等 后续都会学习到;

项目创建成功
二,学习ArkTs
1,自定义组件代码
@Entry
@Component
struct Index {
@State message: string = 'Hello ArkTS'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Text('这是一个文本')
.fontColor(Color.Blue) //设置颜色
.fontSize(20)
Divider() //划线
Text('item 2')
TextInput() //文本输入框
Image('http://p9.itc.cn/q_70/images03/20200718/a27c60c27bcf404bbc7747ea97672f07.png')
.width(100)
}
.width('100%')
}
.height('100%')
}
}
如果需要加载网络图片是需要申请权限,在module.json5
"requestPermissions":[
{
"name" : "ohos.permission.INTERNET",
"reason": "$string:EntryAbility_res",
"usedScene": {
"abilities": [
"FormAbility"
],
"when":"inuse"
}
}
]
网友评论