@Component
@Entry
@Component struct ActivityCard { @Prop activity: ActivityConfig; // 活动配置(来自JSON) @State isClaimed: boolean = false; // 本地缓存状态 build() { Column() { // 根据templateType动态渲染不同模板 if (this.activity.templateType === 'carousel') { this.CarouselTemplate() } Button({ type: ButtonType.Capsule }) .text(this.isClaimed ? '已领取' : '立即领取') .onClick(() => this.handleClaim()) // 点击事件触发状态更新 } } }
@State
提交