@State
const State: PropertyDecorator
卡片能力: 从API version 9开始,该接口支持在ArkTS卡片中使用。
元服务API: 从API version 11开始,该接口支持在元服务中使用。
系统能力: SystemCapability.ArkUI.ArkUI.Full
示例:
@Entry
@Component
struct StateExample {
@State count: number = 0; // 状态变量
build() {
Column() {
Text(`${this.count}`)
}
}
}