-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: expose props type in return for generic component
close #2639
- Loading branch information
1 parent
5a9f46d
commit 184cce1
Showing
5 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<Foo :items="items"> | ||
<template #content="{ item }"> | ||
<div>{{ item.name }}</div> | ||
</template> | ||
</Foo> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import Foo from './Foo.vue'; | ||
type ShowCaseItem = { | ||
name: string; | ||
icon: string; | ||
action: () => void; | ||
index: number; | ||
}; | ||
const items: ShowCaseItem[] = [ | ||
{ | ||
name: 'Instagram Follow Up', | ||
action: () => { | ||
console.log('open IG'); | ||
}, | ||
icon: 'instagramIcon', | ||
index: 0, | ||
}, | ||
{ | ||
name: 'Email Follow Up', | ||
action: () => { | ||
console.log('open email'); | ||
}, | ||
icon: 'envelopeIcon', | ||
index: 1, | ||
}, | ||
] | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div v-for="item in props.items" :key="item.index" > | ||
<slot :item="item" name="content" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts" generic="T extends {index: number}"> | ||
const props = defineProps<{ | ||
items: T[]; | ||
}>(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters