App.vue
SlotComp.vue
main.js
 
<template>
  <h1>Scoped Slots</h1>
  <p>App.vue controls how local data from the scoped slot is rendered.</p>
  <hr>
  <slot-comp v-slot="texts">
    <h2>{{ texts.staticText }}</h2>
    <p class="greenP">{{ texts.dynamicText }}</p>
  </slot-comp>
</template>

<script></script>

<style>
  #app {
    width: 300px;
  }
  h2, .greenP {
    background-color: lightgreen;
    padding: 10px;
  }
</style>                  
<template>
    <slot 
        staticText="This text is static"
        :dynamicText="text"
    ></slot>
</template>

<script>
export default {
    data() {
        return {
            text: 'This text is from the data property'
        }
    }
}
</script>

<style></style>                  
import { createApp } from 'vue'

import App from './App.vue'
import SlotComp from './components/SlotComp.vue'

const app = createApp(App)
app.component('slot-comp', SlotComp)
app.mount('#app')
                  
http://localhost:5173/