装饰器:可装饰类、结构、方法、变量,并赋予他们特殊的含义
如:
@Entry:装饰第一个显示的页面
@Component :装饰组件
@State :装饰变量
等等
自定义组件:可重用的UI单位,可与其它组件配合使用
如:
@Component 装饰的struct Hello
UI描述:声明式描述UI结构
如:
build()方法中的代码块
内置组件:框架中内置的内容、布局组件
如:
Column、Text、Divider、Button等
属性方法:是指组件提供的属性方法
如:
fontSize()、width()、height()等等
事件方法:组件的响应事件方法
如:
Button的onClick()事件等等。
// An example of displaying Hello World. After you click the button, Hello UI is displayed.
@Entry
@Component
struct Hello {
@State myText: string = 'World'
build() {
Column() {
Text('Hello')
.fontSize(30)
Text(this.myText)
.fontSize(32)
Divider()
Button() {
Text('Click me')
.fontColor(Color.Red)
}.onClick(() => {
this.myText = 'UI'
})
.width(500)
.height(200)
}
}
}