Reputation: 1
// App.vue
<template>
<FirstBox>
// no error on this
// <template>
// error on this
<template #default="{ time }">
<div class="text">
<p>time: {{ time }}</p>
<SecondBox name="somedata"></SecondBox>
</div>
</template>
</FirstBox>
</template>
<script setup>
import FirstBox from './FirstBox.vue'
import SecondBox from './SecondBox.vue'
</script>
// FirstBox
<template>
<div class="container">
<slot time="today, today"></slot>
</div>
</template>
<script setup>
import { useSlots } from 'vue'
const slots = useSlots()
console.log(slots.default()) // (destructured parameter) is undefined
</script>
// SecondBox
<template>
<div class="container">
here is: {{ name }}
</div>
</template>
<script setup>
const props = defineProps({
name: {
type: String,
default: () => {
return ''
}
}
})
</script>
i try to get the name value on SecondBox by using useSlots().default() at FirstBox.vue but there is an error on console: '(destructured parameter) is undefined', i find out this is in App.vue when i use '#default="{ time }"' i dont know what to do now...
Upvotes: -4
Views: 20