HarmonyOS

鸿蒙系统开发初学记录


4.声明式开发范式(Stage)

<p><a href="https://bitsai.blog.csdn.net/?type=blog">https://bitsai.blog.csdn.net/?type=blog</a></p> <pre><code>@Entry //@Entry装饰的自定义组件将作为页面的入口。在一个页面中只能设置一个Entry修饰符 @Component //@Component装饰的自定义组件,在组件中声明变量不要用let修饰 struct Index { //自定义参数,默认私有化的,可从外面以对象形式传递进来 params: string //@State 修饰变量,能双向绑定 @State message: string = 'Hello World' //build 声明式的方式描述UI结构。注意该方法体中必须有一个根组件,如果该组件被Entry修饰,这个根组件必须是一个容器组件 build() { Row() { //Column 是内置组件,表示设置一列 Column() { //设置文本及内容 Text(this.message) .fontSize(50) //设置文本大小 .fontWeight(FontWeight.Bold) //设置字体加粗 } .width('100%') //设置宽度 } .height('100%') //设置宽度 } }</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=f5274625ab6f68d2336cd11587e56bd0&amp;amp;file=file.png" alt="" /></p>

页面列表

ITEM_HTML