[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75ZDYYSKCXJ54RKM7CY4Q9T":3,"skill-same:01M75ZDYYSKCXJ54RKM7CY4Q9T":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M75ZDYYSKCXJ54RKM7CY4Q9T","hmos-arkui-statemgt-migration",null,"帮助开发者将ArkUI状态管理从V1迁移到V2。触发场景：(1) V1项目升级到V2；(2) 迁移@Component\u002F@State\u002F@Prop\u002F@Link\u002F@Observed\u002F@ObjectLink\u002F@Provide\u002F@Consume\u002F@Watch\u002F@Reusable装饰器；(3) 迁移LocalStorage\u002FAppStorage\u002FPersistentStorage\u002FEnvironment应用级状态；(4) 将ForEach\u002FLazyForEach迁移到Repeat；(5) 解决animateTo在V2中的兼容问题；(6) 处理V1与V2混用场景；(7) 询问V1和V2装饰器对应关系或差异。","IsKenKenYa\u002Fskills","IsKenKenYa","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F92219680?v=4","01M75Z8AFJBVH1Y9JJWRT35P0Z","是小啃啃呀","01M75Z8AG6RVC5RF6KTJQ7PQKQ",3,"GPL-3.0","https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fharmonyos\u002Fdevelopment\u002Farkui\u002Fhmos-arkui-statemgt-migration\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: hmos-arkui-statemgt-migration\ndescription: 帮助开发者将ArkUI状态管理从V1迁移到V2。触发场景：(1) V1项目升级到V2；(2) 迁移@Component\u002F@State\u002F@Prop\u002F@Link\u002F@Observed\u002F@ObjectLink\u002F@Provide\u002F@Consume\u002F@Watch\u002F@Reusable装饰器；(3) 迁移LocalStorage\u002FAppStorage\u002FPersistentStorage\u002FEnvironment应用级状态；(4) 将ForEach\u002FLazyForEach迁移到Repeat；(5) 解决animateTo在V2中的兼容问题；(6) 处理V1与V2混用场景；(7) 询问V1和V2装饰器对应关系或差异。\n---\n\n# 状态管理 V1-V2 迁移\n\n## 核心迁移映射\n\n### 组件装饰器\n\n| V1 | V2 | 说明 |\n|---|---|---|\n| `@Component` | `@ComponentV2` | 组件装饰器 |\n| `@State` | `@Local` \u002F `@Param @Once` | 内部状态；需外部初始化用`@Param @Once` |\n| `@Prop` | `@Param` | 父→子单向传递；V2的`@Param`只读，`@Param`需要给初始值 |\n| `@Link` | `@Param` + `@Event` | 双向同步需手动实现 |\n| `@Observed` | `@ObservedV2` | 标记可观察类 |\n| `@ObjectLink` | `@ObservedV2` + `@Trace` | 深度观测嵌套对象 |\n| `@Track` | `@Trace` | 属性级精确观测 |\n| `@Provide\u002F@Consume` | `@Provider\u002F@Consumer` | 跨组件状态共享 |\n| `@Watch` | `@Monitor` | 状态变化监听 |\n| `@Reusable` | `@ReusableV2` | 组件复用 |\n| 无 | `@Computed` | 计算属性（V2新增） |\n\n> 详细迁移示例参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n### 应用级状态\n\n| V1 | V2 | 说明 |\n|---|---|---|\n| `LocalStorage` | `@ObservedV2` + `@Trace` 单例 | 页面间状态共享 |\n| `@LocalStorageLink` | `@Local` + 单例引用 | 双向同步LocalStorage数据 |\n| `@LocalStorageProp` | `@Local` + `@Monitor` | 单向接收，本地修改不同步 |\n| `AppStorage` | `AppStorageV2+`@ObservedV2` + `@Trace`提供存储单例 | +跨Ability状态共享 |\n| `AppStorage.setOrCreate` | `AppStorageV2.connect()`+借助类传递变量 | 创建共享状态 |\n| `@StorageLink` | `AppStorageV2.connect()` + `@Local` 需要借助类 | 双向同步AppStorage数据 |\n| `@StorageProp` | `@Local` + `@Monitor`需要借助类传递 | 单向接收，本地修改不同步 |\n| `PersistentStorage` | `PersistenceV2` | 持久化存储 |\n| `Environment` | `UIAbilityContext.config` | 系统环境变量 |\n\n> 详细迁移示例参考：`references\u002Farkts-v1-v2-migration-application.md`\n\n### 渲染控制\n\n| V1 | V2 | 说明 |\n|---|---|---|\n| `ForEach` | `Repeat` | 全量加载循环渲染 |\n| `LazyForEach` | `Repeat` + `.virtualScroll()` | 懒加载循环渲染 |\n| `$$` | `!!` | 双向绑定语法糖 |\n\n> 详细迁移示例参考：`references\u002Farkts-v1-v2-migration-rendering-control-repeat.md`\n\n## 核心差异\n\n| 特性 | V1 | V2 |\n|------|----|----|\n| 观测深度 | `@State`可观测第一层属性 | `@Local`只观测本身，需`@ObservedV2`+`@Trace`深度观测 |\n| 初始化 | `@State`支持外部初始化 | `@Local`禁止外部初始化，需用`@Param @Once` |\n| 双向绑定 | `@Link`内置双向同步 | 无内置，需`@Param`+`@Event`手动实现 |\n| 参数传递 | `@Prop`可本地修改 | `@Param`只读，修改需`@Once`或`@Event` |\n\n## 迁移工作流程\n\n### 阶段一：环境准备\n1. **版本检查** - 确认API版本≥12，低于api12需先升级版本\n2. **依赖评估** - 确认三方库兼容性\n3. **备份代码** - 创建迁移前备份分支\n\n### 阶段二：代码分析\n1. **扫描装饰器** - 使用grep扫描`@Component|@State|@Prop|@Link|@Observed|@ObjectLink|@Provide|@Consume|@Watch|@Reusable|@StorageLink|@StorageProp|@LocalStorageLink|@LocalStorageProp`\n2. **识别组件** - 列出所有使用V1装饰器的组件文件\n3. **分析依赖** - 识别组件间的父子关系和数据流向\n4. **生成清单** - 按文件生成迁移清单\n\n### 阶段三：制定计划\n1. **优先级排序** - 叶子组件优先，逐层向上迁移\n2. **批次划分** - 按功能模块分批次迁移\n3. **风险评估** - 识别混用风险点\n\n### 阶段四：执行迁移（按类型顺序）\n\n#### 4.1 组件装饰器迁移\n```\n@Entry保持不变\n@Component → @ComponentV2\n@State → @Local\n@Prop → @Param \u002F\u002F 狐疑@Params要给初始值，或者给@Require\n@Link → @Param + @Event\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n#### 4.2 数据对象迁移\n```\n@Observed → @ObservedV2\n@ObjectLink → @ObservedV2 + @Trace\n@Track → @Trace\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-class.md`\n\n#### 4.3 跨组件状态迁移\n```\n@Provide\u002F@Consume → @Provider\u002F@Consumer\n@Watch → @Monitor\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n#### 4.4 应用级状态迁移\n```\nLocalStorage → @ObservedV2单例\n@LocalStorageLink → @Local + 单例引用\n@LocalStorageProp → @Local + @Monitor\nAppStorage → AppStorageV2\n@StorageLink → 参考`references\u002Farkts-v1-v2-migration-application.md`中的storageLink迁移\n@StorageProp → 参考`references\u002Farkts-v1-v2-migration-application.md`中的storageProp迁移\nPersistentStorage → PersistenceV2\nEnvironment → UIAbilityContext.config\n```\n> 参考：`references\u002Farkts-v1-v2-migration-application.md`\n\n#### 4.5 渲染控制迁移\n```\nForEach → Repeat\nLazyForEach → Repeat + .virtualScroll()\n```\n> 参考：`references\u002Farkts-v1-v2-migration-rendering-control-repeat.md`\n\n#### 4.6 组件复用迁移\n```\n@Reusable → @ReusableV2\n```\n> 参考：`references\u002Farkts-v1-v2-migration-reusable.md`\n\n### 阶段五：特殊场景处理\n\n#### 滚动组件内置对象\nList\u002FWaterFlow的`ChildrenMainSize`\u002F`WaterFlowSections`需用`UIUtils.makeObserved()`包装：\n```typescript\nimport { UIUtils } from '@kit.ArkUI';\nlistChildrenSize = UIUtils.makeObserved(new ChildrenMainSize(100));\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-object.md`\n\n#### animateTo兼容\nV2中animateTo前的状态修改可能不生效，需用`UIUtils.applySync()`：\n```typescript\nimport { UIUtils } from '@kit.ArkUI';\nUIUtils.applySync(() => { this.w = 100; });\nthis.getUIContext().animateTo({ duration: 1000 }, () => { this.w = 200; });\n```\n> 参考：`references\u002Farkts-v1-v2-migration-animateTo.md`\n\n#### 双向绑定\n`$$`语法替换为`!!`\n> 参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n### 阶段六：验证测试\n1. **编译检查** - 确保无语法错误\n2. **功能测试** - 验证组件交互正常\n3. **性能测试** - 检查渲染性能\n4. **回归测试** - 全功能覆盖验证\n\n## 详细迁移指南\n\n### 按迁移阶段查阅\n\n| 迁移阶段 | 参考文档 | 核心内容 |\n|---------|----------|---------|\n| **阶段一：环境准备** | `references\u002Farkts-v1-v2-migration.md` | V1\u002FV2差异对比、API版本要求、混用规则 |\n| **阶段四：执行迁移** | | |\n| 4.1 组件装饰器 | `references\u002Farkts-v1-v2-migration-inner-component.md` | @State\u002F@Prop\u002F@Link\u002F@Provide\u002F@Consume\u002F@Watch迁移完整示例 |\n| 4.2 数据对象 | `references\u002Farkts-v1-v2-migration-inner-class.md` | @Observed\u002F@ObjectLink\u002F@Track → @ObservedV2\u002F@Trace，嵌套对象观测 |\n| 4.4 应用级状态 | `references\u002Farkts-v1-v2-migration-application.md` | LocalStorage\u002FAppStorage\u002FPersistentStorage\u002FEnvironment完整示例 |\n| 4.5 渲染控制 | `references\u002Farkts-v1-v2-migration-rendering-control-repeat.md` | ForEach\u002FLazyForEach → Repeat，数据更新、拖拽排序 |\n| 4.6 组件复用 | `references\u002Farkts-v1-v2-migration-reusable.md` | @Reusable → @ReusableV2，aboutToReuse变化 |\n| **阶段五：特殊场景** | | |\n| 内置对象 | `references\u002Farkts-v1-v2-migration-inner-object.md` | List\u002FWaterFlow滚动组件、Modifier迁移、makeObserved用法 |\n| animateTo | `references\u002Farkts-v1-v2-migration-animateTo.md` | V2中animateTo兼容问题、applySync用法 |\n\n### 文档查阅建议\n\n**首次迁移**：按顺序阅读所有文档，建立整体认知\n\n**快速查阅**：\n- 组件迁移问题 → `inner-component.md`\n- 嵌套对象观测 → `inner-class.md`\n- 滚动列表异常 → `inner-object.md` + `rendering-control-repeat.md`\n- 动画不生效 → `animateTo.md`\n- 状态持久化 → `application.md`\n\n## 关键注意事项\n\n### 初始值\n`@Param` 和 `@Consumer` 需要有初始值：\n```typescript\n@Consumer('navPathStack') navPathStack: NavPathStack = new NavPathStack();\n@Param todo: Todo = new Todo();\n```\n无法给初始值时，使用`@Require`装饰器：\n```typescript\n@Require @Consumer('navPathStack') navPathStack: NavPathStack;\n@Require @Param todo: Todo;\n```\n\n### 观测能力差异\n- V1的`@State`可观测第一层属性\n- V2的`@Local`只观测本身，需配合`@ObservedV2`+`@Trace`实现深度观测\n\n## 迁移检查清单\n\n- [ ] `@Component` → `@ComponentV2`\n- [ ] `@State` → `@Local` 或 `@Param @Once`\n- [ ] `@Prop` → `@Param`\n- [ ] `@Link` → `@Param` + `@Event`\n- [ ] `@Observed\u002F@ObjectLink` → `@ObservedV2\u002F@Trace`\n- [ ] `@Provide\u002F@Consume` → `@Provider\u002F@Consumer`\n- [ ] `@Watch` → `@Monitor`\n- [ ] `@Reusable` → `@ReusableV2`\n- [ ] `LocalStorage` → `@ObservedV2`单例\n- [ ] `@LocalStorageLink` → `@Local` + 单例引用\n- [ ] `@LocalStorageProp` → `@Local` + `@Monitor`\n- [ ] `PersistentStorage` → `PersistenceV2`\n- [ ] `ForEach` → `Repeat`\n- [ ] `LazyForEach` → `Repeat` + `.virtualScroll()`\n- [ ] `$$` → `!!`\n- [ ] 滚动组件内置对象使用`makeObserved`\n- [ ] animateTo前的状态修改使用`applySync`\n\n## 参考资料\n\n1、Appstorev2的使用：[AppStorageV2: 应用全局UI状态存储-管理应用拥有的状态-状态管理（V2）-学习UI范式状态管理-UI开发 (ArkTS声明式开发范式)-ArkUI（方舟UI框架）-应用框架 - 华为HarmonyOS开发者](https:\u002F\u002Fdeveloper.huawei.com\u002Fconsumer\u002Fcn\u002Fdoc\u002Fharmonyos-guides\u002Farkts-new-appstoragev2)","# 状态管理 V1-V2 迁移\n\n## 核心迁移映射\n\n### 组件装饰器\n\n| V1 | V2 | 说明 |\n|---|---|---|\n| `@Component` | `@ComponentV2` | 组件装饰器 |\n| `@State` | `@Local` \u002F `@Param @Once` | 内部状态；需外部初始化用`@Param @Once` |\n| `@Prop` | `@Param` | 父→子单向传递；V2的`@Param`只读，`@Param`需要给初始值 |\n| `@Link` | `@Param` + `@Event` | 双向同步需手动实现 |\n| `@Observed` | `@ObservedV2` | 标记可观察类 |\n| `@ObjectLink` | `@ObservedV2` + `@Trace` | 深度观测嵌套对象 |\n| `@Track` | `@Trace` | 属性级精确观测 |\n| `@Provide\u002F@Consume` | `@Provider\u002F@Consumer` | 跨组件状态共享 |\n| `@Watch` | `@Monitor` | 状态变化监听 |\n| `@Reusable` | `@ReusableV2` | 组件复用 |\n| 无 | `@Computed` | 计算属性（V2新增） |\n\n> 详细迁移示例参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n### 应用级状态\n\n| V1 | V2 | 说明 |\n|---|---|---|\n| `LocalStorage` | `@ObservedV2` + `@Trace` 单例 | 页面间状态共享 |\n| `@LocalStorageLink` | `@Local` + 单例引用 | 双向同步LocalStorage数据 |\n| `@LocalStorageProp` | `@Local` + `@Monitor` | 单向接收，本地修改不同步 |\n| `AppStorage` | `AppStorageV2+`@ObservedV2` + `@Trace`提供存储单例 | +跨Ability状态共享 |\n| `AppStorage.setOrCreate` | `AppStorageV2.connect()`+借助类传递变量 | 创建共享状态 |\n| `@StorageLink` | `AppStorageV2.connect()` + `@Local` 需要借助类 | 双向同步AppStorage数据 |\n| `@StorageProp` | `@Local` + `@Monitor`需要借助类传递 | 单向接收，本地修改不同步 |\n| `PersistentStorage` | `PersistenceV2` | 持久化存储 |\n| `Environment` | `UIAbilityContext.config` | 系统环境变量 |\n\n> 详细迁移示例参考：`references\u002Farkts-v1-v2-migration-application.md`\n\n### 渲染控制\n\n| V1 | V2 | 说明 |\n|---|---|---|\n| `ForEach` | `Repeat` | 全量加载循环渲染 |\n| `LazyForEach` | `Repeat` + `.virtualScroll()` | 懒加载循环渲染 |\n| `$$` | `!!` | 双向绑定语法糖 |\n\n> 详细迁移示例参考：`references\u002Farkts-v1-v2-migration-rendering-control-repeat.md`\n\n## 核心差异\n\n| 特性 | V1 | V2 |\n|------|----|----|\n| 观测深度 | `@State`可观测第一层属性 | `@Local`只观测本身，需`@ObservedV2`+`@Trace`深度观测 |\n| 初始化 | `@State`支持外部初始化 | `@Local`禁止外部初始化，需用`@Param @Once` |\n| 双向绑定 | `@Link`内置双向同步 | 无内置，需`@Param`+`@Event`手动实现 |\n| 参数传递 | `@Prop`可本地修改 | `@Param`只读，修改需`@Once`或`@Event` |\n\n## 迁移工作流程\n\n### 阶段一：环境准备\n1. **版本检查** - 确认API版本≥12，低于api12需先升级版本\n2. **依赖评估** - 确认三方库兼容性\n3. **备份代码** - 创建迁移前备份分支\n\n### 阶段二：代码分析\n1. **扫描装饰器** - 使用grep扫描`@Component|@State|@Prop|@Link|@Observed|@ObjectLink|@Provide|@Consume|@Watch|@Reusable|@StorageLink|@StorageProp|@LocalStorageLink|@LocalStorageProp`\n2. **识别组件** - 列出所有使用V1装饰器的组件文件\n3. **分析依赖** - 识别组件间的父子关系和数据流向\n4. **生成清单** - 按文件生成迁移清单\n\n### 阶段三：制定计划\n1. **优先级排序** - 叶子组件优先，逐层向上迁移\n2. **批次划分** - 按功能模块分批次迁移\n3. **风险评估** - 识别混用风险点\n\n### 阶段四：执行迁移（按类型顺序）\n\n#### 4.1 组件装饰器迁移\n```\n@Entry保持不变\n@Component → @ComponentV2\n@State → @Local\n@Prop → @Param \u002F\u002F 狐疑@Params要给初始值，或者给@Require\n@Link → @Param + @Event\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n#### 4.2 数据对象迁移\n```\n@Observed → @ObservedV2\n@ObjectLink → @ObservedV2 + @Trace\n@Track → @Trace\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-class.md`\n\n#### 4.3 跨组件状态迁移\n```\n@Provide\u002F@Consume → @Provider\u002F@Consumer\n@Watch → @Monitor\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n#### 4.4 应用级状态迁移\n```\nLocalStorage → @ObservedV2单例\n@LocalStorageLink → @Local + 单例引用\n@LocalStorageProp → @Local + @Monitor\nAppStorage → AppStorageV2\n@StorageLink → 参考`references\u002Farkts-v1-v2-migration-application.md`中的storageLink迁移\n@StorageProp → 参考`references\u002Farkts-v1-v2-migration-application.md`中的storageProp迁移\nPersistentStorage → PersistenceV2\nEnvironment → UIAbilityContext.config\n```\n> 参考：`references\u002Farkts-v1-v2-migration-application.md`\n\n#### 4.5 渲染控制迁移\n```\nForEach → Repeat\nLazyForEach → Repeat + .virtualScroll()\n```\n> 参考：`references\u002Farkts-v1-v2-migration-rendering-control-repeat.md`\n\n#### 4.6 组件复用迁移\n```\n@Reusable → @ReusableV2\n```\n> 参考：`references\u002Farkts-v1-v2-migration-reusable.md`\n\n### 阶段五：特殊场景处理\n\n#### 滚动组件内置对象\nList\u002FWaterFlow的`ChildrenMainSize`\u002F`WaterFlowSections`需用`UIUtils.makeObserved()`包装：\n```typescript\nimport { UIUtils } from '@kit.ArkUI';\nlistChildrenSize = UIUtils.makeObserved(new ChildrenMainSize(100));\n```\n> 参考：`references\u002Farkts-v1-v2-migration-inner-object.md`\n\n#### animateTo兼容\nV2中animateTo前的状态修改可能不生效，需用`UIUtils.applySync()`：\n```typescript\nimport { UIUtils } from '@kit.ArkUI';\nUIUtils.applySync(() => { this.w = 100; });\nthis.getUIContext().animateTo({ duration: 1000 }, () => { this.w = 200; });\n```\n> 参考：`references\u002Farkts-v1-v2-migration-animateTo.md`\n\n#### 双向绑定\n`$$`语法替换为`!!`\n> 参考：`references\u002Farkts-v1-v2-migration-inner-component.md`\n\n### 阶段六：验证测试\n1. **编译检查** - 确保无语法错误\n2. **功能测试** - 验证组件交互正常\n3. **性能测试** - 检查渲染性能\n4. **回归测试** - 全功能覆盖验证\n\n## 详细迁移指南\n\n### 按迁移阶段查阅\n\n| 迁移阶段 | 参考文档 | 核心内容 |\n|---------|----------|---------|\n| **阶段一：环境准备** | `references\u002Farkts-v1-v2-migration.md` | V1\u002FV2差异对比、API版本要求、混用规则 |\n| **阶段四：执行迁移** | | |\n| 4.1 组件装饰器 | `references\u002Farkts-v1-v2-migration-inner-component.md` | @State\u002F@Prop\u002F@Link\u002F@Provide\u002F@Consume\u002F@Watch迁移完整示例 |\n| 4.2 数据对象 | `references\u002Farkts-v1-v2-migration-inner-class.md` | @Observed\u002F@ObjectLink\u002F@Track → @ObservedV2\u002F@Trace，嵌套对象观测 |\n| 4.4 应用级状态 | `references\u002Farkts-v1-v2-migration-application.md` | LocalStorage\u002FAppStorage\u002FPersistentStorage\u002FEnvironment完整示例 |\n| 4.5 渲染控制 | `references\u002Farkts-v1-v2-migration-rendering-control-repeat.md` | ForEach\u002FLazyForEach → Repeat，数据更新、拖拽排序 |\n| 4.6 组件复用 | `references\u002Farkts-v1-v2-migration-reusable.md` | @Reusable → @ReusableV2，aboutToReuse变化 |\n| **阶段五：特殊场景** | | |\n| 内置对象 | `references\u002Farkts-v1-v2-migration-inner-object.md` | List\u002FWaterFlow滚动组件、Modifier迁移、makeObserved用法 |\n| animateTo | `references\u002Farkts-v1-v2-migration-animateTo.md` | V2中animateTo兼容问题、applySync用法 |\n\n### 文档查阅建议\n\n**首次迁移**：按顺序阅读所有文档，建立整体认知\n\n**快速查阅**：\n- 组件迁移问题 → `inner-component.md`\n- 嵌套对象观测 → `inner-class.md`\n- 滚动列表异常 → `inner-object.md` + `rendering-control-repeat.md`\n- 动画不生效 → `animateTo.md`\n- 状态持久化 → `application.md`\n\n## 关键注意事项\n\n### 初始值\n`@Param` 和 `@Consumer` 需要有初始值：\n```typescript\n@Consumer('navPathStack') navPathStack: NavPathStack = new NavPathStack();\n@Param todo: Todo = new Todo();\n```\n无法给初始值时，使用`@Require`装饰器：\n```typescript\n@Require @Consumer('navPathStack') navPathStack: NavPathStack;\n@Require @Param todo: Todo;\n```\n\n### 观测能力差异\n- V1的`@State`可观测第一层属性\n- V2的`@Local`只观测本身，需配合`@ObservedV2`+`@Trace`实现深度观测\n\n## 迁移检查清单\n\n- [ ] `@Component` → `@ComponentV2`\n- [ ] `@State` → `@Local` 或 `@Param @Once`\n- [ ] `@Prop` → `@Param`\n- [ ] `@Link` → `@Param` + `@Event`\n- [ ] `@Observed\u002F@ObjectLink` → `@ObservedV2\u002F@Trace`\n- [ ] `@Provide\u002F@Consume` → `@Provider\u002F@Consumer`\n- [ ] `@Watch` → `@Monitor`\n- [ ] `@Reusable` → `@ReusableV2`\n- [ ] `LocalStorage` → `@ObservedV2`单例\n- [ ] `@LocalStorageLink` → `@Local` + 单例引用\n- [ ] `@LocalStorageProp` → `@Local` + `@Monitor`\n- [ ] `PersistentStorage` → `PersistenceV2`\n- [ ] `ForEach` → `Repeat`\n- [ ] `LazyForEach` → `Repeat` + `.virtualScroll()`\n- [ ] `$$` → `!!`\n- [ ] 滚动组件内置对象使用`makeObserved`\n- [ ] animateTo前的状态修改使用`applySync`\n\n## 参考资料\n\n1、Appstorev2的使用：[AppStorageV2: 应用全局UI状态存储-管理应用拥有的状态-状态管理（V2）-学习UI范式状态管理-UI开发 (ArkTS声明式开发范式)-ArkUI（方舟UI框架）-应用框架 - 华为HarmonyOS开发者](https:\u002F\u002Fdeveloper.huawei.com\u002Fconsumer\u002Fcn\u002Fdoc\u002Fharmonyos-guides\u002Farkts-new-appstoragev2)",{"name":5,"description":7},"main","581098187aec1258c6d9e65e1b9866c2e7381167","skills\u002Fharmonyos\u002Fdevelopment\u002Farkui\u002Fhmos-arkui-statemgt-migration",0,"https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills","https:\u002F\u002Fgithub.com\u002FIsKenKenYa","是小啃啃呀-一个初学者，中国开源共享推动者之一。\r\n未来，会涉及OpenHarmony、HarmonyOS（部分应用开源）、Android Open Sources Project等。\r\n\r\n目前正在学习中，欢迎友善的讨论。","2026-10-08 01:02:25",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add IsKenKenYa\u002Fskills --skill hmos-arkui-statemgt-migration",{"tool":38,"command":39},"bunx","bunx skills add IsKenKenYa\u002Fskills --skill hmos-arkui-statemgt-migration",{"tool":41,"command":42},"pnpm","pnpm dlx skills add IsKenKenYa\u002Fskills --skill hmos-arkui-statemgt-migration","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fharmonyos\u002Fdevelopment\u002Farkui\u002Fhmos-arkui-statemgt-migration\u002FSKILL.md",true,[46],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"test-cases\u002Fv1-to-v2-migration-test-cases.md","REFERENCE","参考文档",50743,"https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fharmonyos\u002Fdevelopment\u002Farkui\u002Fhmos-arkui-statemgt-migration\u002Ftest-cases\u002Fv1-to-v2-migration-test-cases.md",[53,60,67,74,81,88],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M75ZN00W20TC7TJ40TDM7E4X","writing-for-agents","为 agent 撰写文档。当创建或编辑 skill、修改 AGENTS.md 或 CLAUDE.md 时使用。","https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M75ZMZ63RYMNRTPEXW5T82S6","wait-what","停。上一条消息没讲明白：换个说法再讲一遍。","https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fwait-what\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M75ZMXZT6MGCGFMKRTM6V6GW","to-questionnaire","把你无法独自回答的决策转化成一份问卷，交给别人填写。","https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fto-questionnaire\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M75ZMWQGNJW3E592V94ZYJMX","teach","在当前工作区内，教会用户一项新 skill 或概念。","https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fteach\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M75ZMVQREJR3YDK0XED9AJHB","handoff","把当前对话压缩成一份交接（handoff）文档，供另一个代理接手。","https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fhandoff\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M75ZMTQAAFGA7QH26WK9Z936","grilling","就一个计划、决策或想法对用户进行无情的访谈。当用户想压力测试自己的思路，或使用任何 'grill' 触发短语时使用。","https:\u002F\u002Fgithub.com\u002FIsKenKenYa\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fgrilling\u002FSKILL.md",[],[]]