hmos-arkui-statemgt-migration
Installation
SKILL.md
状态管理 V1-V2 迁移
核心迁移映射
组件装饰器
| V1 | V2 | 说明 |
|---|---|---|
@Component |
@ComponentV2 |
组件装饰器 |
@State |
@Local / @Param @Once |
内部状态;需外部初始化用@Param @Once |
@Prop |
@Param |
父→子单向传递;V2的@Param只读,@Param需要给初始值 |
@Link |
@Param + @Event |
双向同步需手动实现 |
@Observed |
@ObservedV2 |
标记可观察类 |
@ObjectLink |
@ObservedV2 + @Trace |
深度观测嵌套对象 |
@Track |
@Trace |
属性级精确观测 |
@Provide/@Consume |
@Provider/@Consumer |
跨组件状态共享 |
@Watch |
@Monitor |
状态变化监听 |
@Reusable |
@ReusableV2 |
组件复用 |
| 无 | @Computed |
计算属性(V2新增) |