HarmonyOS 鸿蒙Next 公共的头部如何实现,带有标题和返回按钮
HarmonyOS 鸿蒙Next 公共的头部如何实现,带有标题和返回按钮
公共的头部如何实现,带有标题和返回按钮
2 回复
可参考
[@Component](/user/Component)
struct CommonTitle{
build(){
Flex({justifyContent: FlexAlign.Center}){
Image($r('app.media.arrow_left')).width(24)
Column(){
Text('我是标题')
.fontSize(24)
}
.alignItems(HorizontalAlign.Center)
.width('calc(100% - 24vp)')
}
.width(<span class="hljs-string">'100%'</span>)
}
}
@Entry
@Component
struct ShangH_issue06_01 {
@State message: string = ‘Hello World’;
build() {
Column() {
CommonTitle();
Text(this.message)
.id(‘ShangH_issue06_01HelloWorld’)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: ‘container’, align: VerticalAlign.Center },
middle: { anchor: ‘container’, align: HorizontalAlign.Center }
}).backgroundColor(Color.Pink)
.onClick(() => {
})
}
.padding(10)
.height(‘100%’)
.width(‘100%’)
}
}
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>