HarmonyOS鸿蒙Next中通用属性width是否支持设置变量
HarmonyOS鸿蒙Next中通用属性width是否支持设置变量
通用属性width支持设置变量,示例如下:
@Entry
@Component
struct Page1 {
@State message: string = 'Hello';
@State widNum: number = 300;
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.width(this.widNum)
.backgroundColor(Color.Blue)
}
.width('100%')
}
.height('100%')
}
}
效果如下:

