Files
harmony-client/uikit/src/main/ets/components/Avatar.ets
2026-09-11 20:47:22 +08:00

24 lines
568 B
Plaintext

import { AppColor } from '../theme/Theme';
/**
* 首字母圆形头像:金色底白字。
*/
@ComponentV2
export struct Avatar {
@Param name: string = '';
@Param diameter: number = 40;
build() {
Stack({ alignContent: Alignment.Center }) {
Text(this.name.length > 0 ? this.name.charAt(0) : '明')
.fontSize(this.diameter * 0.42)
.fontWeight(FontWeight.Bold)
.fontColor(AppColor.white)
}
.width(this.diameter)
.height(this.diameter)
.borderRadius(this.diameter / 2)
.backgroundColor(AppColor.gold)
}
}