V-for&useSlots related errors
Vue version
3.3.4
Link to minimal reproduction
https://github.com/qiuqiuma/vue-test
Steps to reproduce
The following issues occur when I use the "default slot" ===(The first is a normal example)=== ----define component-----
<template>
<div>
<slot></slot>
</div>
</template>
<script setup>
import { useSlots } from "vue";
const slots = useSlots();
const res = slots.default();
debugger
</script>
----Usage component----
<script setup lang="ts">
import Test from './compoents/Test.vue'
</script>
<template>
<div>
<Test>
<div>1</div>
<div>2</div>
<div>3</div>
</Test>
</div>
</template>
===(Next is the bug example)=== ---When I use "v-for" to render the content---
<script setup lang="ts">
import Test from './compoents/Test.vue'
const arr = [1,2,3]
</script>
<template>
<div>
<Test>
<div v-for="(item,index) in arr" :key="index"> {{ item }}</div>
</Test>
</div>
</template>
The structure of the object has changed
What is expected?
The content rendered by v for is the same as that presented by regular writing, so the data structure received using useSlots should also be the same
What is actually happening?
The content rendered through the v-for loop through useSlots should not have an extra blank level
System Info
No response
Any additional comments?
No response
this is by design, v-for render as a fragment. Check as follows:
import { Fragment } from 'vue'
if(res.type === Fragment){
}