Last active
December 30, 2020 08:14
-
-
Save minhntm/3be5affcf964c67d70603aed19cc775e to your computer and use it in GitHub Desktop.
How to use Vue's slot
This file contains hidden or 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
<template> | |
<div class="book"> | |
<slot name="title" | |
:bookTitle="bookTitle" | |
/> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
bookTitle: 'Child Providing Data' | |
} | |
} | |
} | |
</scipt> |
This file contains hidden or 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
<template> | |
<Book> | |
<template v-slot:title="slotProps"> | |
<h1>{{ slotProps.bookTilte }}</h1> | |
</template> | |
</Book> | |
</template> | |
// or | |
<template> | |
<Book> | |
<template v-slot:title="{ bookTitle }"> | |
<h1>{{ bookTilte }}</h1> | |
</template> | |
</Book> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment