slots in vue js code example
Example: v-slot="slotProps" in vue
<template>
<div class="message">
<slot :firstName="firstName"></slot>
</div>
</template><script>
export default { name: "MyMessage",
data() { return { firstName: "Luca", };
},};
</script>
<style scoped>
.message { color: red; text-decoration: underline;}
</style>
<template>
<my-message>
<template v-slot="slotProps">
<h1>Hey {{ slotProps.firstName }}, NotOnlyCSS is awesome!</h1>
</template>
</my-message>
</template>
<script>
import MyMessage from "./components/MyMessage.vue";
export default {
name: "App",
components: {
MyMessage,
},
};
</script>