diff --git a/arkts-development/SKILL.md b/arkts-development/SKILL.md index 53710c8..927e64b 100644 --- a/arkts-development/SKILL.md +++ b/arkts-development/SKILL.md @@ -96,7 +96,11 @@ router.replaceUrl({ url: 'pages/New' }); router.back(); // Get params -const params = router.getParams() as Record; +interface RouteParams { + id: number; + title?: string; +} +const params = router.getParams() as RouteParams; ``` ## Network Request diff --git a/arkts-development/assets/list-page-template.ets b/arkts-development/assets/list-page-template.ets index d190c0c..7c817b5 100644 --- a/arkts-development/assets/list-page-template.ets +++ b/arkts-development/assets/list-page-template.ets @@ -20,18 +20,21 @@ struct {{PageName}} { this.loadItems(); } - async loadItems(): Promise { - this.isLoading = true; - try { - // TODO: Fetch items from API - this.items = [ - { id: '1', title: 'Item 1', description: 'Description 1' }, - { id: '2', title: 'Item 2', description: 'Description 2' }, - ]; - } finally { - this.isLoading = false; - } - } + async loadItems(): Promise { + this.isLoading = true; + try { + // TODO: Fetch items from API + this.items = [ + { id: '1', title: 'Item 1', description: 'Description 1' }, + { id: '2', title: 'Item 2', description: 'Description 2' }, + ]; + } catch (error) { + console.error('Failed to load items:', error); + // TODO: Show error message to user + } finally { + this.isLoading = false; + } + } async refreshItems(): Promise { this.isRefreshing = true; diff --git a/arkts-development/references/api-reference.md b/arkts-development/references/api-reference.md index 891aeaf..fb071e4 100644 --- a/arkts-development/references/api-reference.md +++ b/arkts-development/references/api-reference.md @@ -65,24 +65,31 @@ router.back({ url: 'pages/HomePage' }); -// Back with result -router.back({ - url: 'pages/HomePage', - params: { result: 'success' } -}); -``` - -### Get Parameters - -```typescript -// In target page -aboutToAppear(): void { - const params = router.getParams() as Record; - if (params) { - const id = params['id'] as number; - const title = params['title'] as string; - } -} +// Back with result +router.back({ + url: 'pages/HomePage', + params: { result: 'success' } +}); +// Note: Previous page receives params via router.getParams() +``` + +### Get Parameters + +```typescript +// Define expected params interface +interface PageParams { + id: number; + title?: string; +} + +// In target page +aboutToAppear(): void { + const params = router.getParams() as PageParams; + if (params) { + const id = params.id; + const title = params.title; + } +} ``` ### Get Router State