feat(组件通信): 暴露FamilyAlbum刷新方法供父组件调用
在FamilyAlbum组件中通过defineExpose暴露refreshData方法 父组件Dashboard通过ref调用该方法刷新相册数据
Showing
2 changed files
with
12 additions
and
1 deletions
| ... | @@ -168,6 +168,11 @@ onMounted(() => { | ... | @@ -168,6 +168,11 @@ onMounted(() => { |
| 168 | useDidShow(() => { | 168 | useDidShow(() => { |
| 169 | fetchAlbumData(); | 169 | fetchAlbumData(); |
| 170 | }); | 170 | }); |
| 171 | + | ||
| 172 | +// 暴露刷新方法给父组件 | ||
| 173 | +defineExpose({ | ||
| 174 | + refreshData: fetchAlbumData, | ||
| 175 | +}); | ||
| 171 | </script> | 176 | </script> |
| 172 | 177 | ||
| 173 | <style lang="less" scoped> | 178 | <style lang="less" scoped> | ... | ... |
| ... | @@ -138,7 +138,7 @@ | ... | @@ -138,7 +138,7 @@ |
| 138 | <RankingCard ref="rankingCardRef" :onViewMore="openFamilyRank" /> | 138 | <RankingCard ref="rankingCardRef" :onViewMore="openFamilyRank" /> |
| 139 | 139 | ||
| 140 | <!-- Family album --> | 140 | <!-- Family album --> |
| 141 | - <FamilyAlbum /> | 141 | + <FamilyAlbum ref="familyAlbumRef" /> |
| 142 | 142 | ||
| 143 | <BottomNav /> | 143 | <BottomNav /> |
| 144 | 144 | ||
| ... | @@ -181,6 +181,7 @@ const rankingCardRef = ref(null) | ... | @@ -181,6 +181,7 @@ const rankingCardRef = ref(null) |
| 181 | const showTotalPointsOnly = ref(false) | 181 | const showTotalPointsOnly = ref(false) |
| 182 | const finalTotalPoints = ref(0) | 182 | const finalTotalPoints = ref(0) |
| 183 | const pendingPoints = ref([]) // 待收集的积分数据 | 183 | const pendingPoints = ref([]) // 待收集的积分数据 |
| 184 | +const familyAlbumRef = ref(null) | ||
| 184 | 185 | ||
| 185 | const familyName = ref('') | 186 | const familyName = ref('') |
| 186 | const familySlogn = ref('') | 187 | const familySlogn = ref('') |
| ... | @@ -382,6 +383,11 @@ useDidShow(async () => { | ... | @@ -382,6 +383,11 @@ useDidShow(async () => { |
| 382 | rankingCardRef.value.refreshData(); | 383 | rankingCardRef.value.refreshData(); |
| 383 | } | 384 | } |
| 384 | 385 | ||
| 386 | + // 刷新相册数据 | ||
| 387 | + if (familyAlbumRef.value) { | ||
| 388 | + familyAlbumRef.value.refreshData(); | ||
| 389 | + } | ||
| 390 | + | ||
| 385 | // TODO: 获取广告信息 | 391 | // TODO: 获取广告信息 |
| 386 | adObj.value = { | 392 | adObj.value = { |
| 387 | adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg', | 393 | adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg', | ... | ... |
-
Please register or login to post a comment