1、目标需求
界面有增大字体按钮,每次点击增大字体按钮,“Hello ArkTS”都会变大
2、源代码
@Entry
@Component
struct Page {
textValue: string = 'Hello ArkTS'
@State textSize: number = 50
myClick():void{
this.textSize += 4
}
build() {
Row() {
Column() {
// @ts-ignore
Text(this.textValue)
.fontSize(this.textSize)
.fontWeight(FontWeight.Bold)
.fontColor(Color.Red)
Button("点击增大哦")
.height(50)
.width(100)
.margin({top:20})
.onClick(this.myClick.bind(this))
}
.width('100%')
}
.height('100%')
}
}
3、运行效果
4、知识点总结
持续学习更新,学成挣大钱。太忙,可能会迟到,但不会缺席!
欢迎每个小伙伴关注收藏,会全部回关,永远不会取消!