如何获取列表渲染的插槽实例集合?How to get a v-for slot instances? #11457
Answered
by
s3xysteak
inside5545
asked this question in
Help/Questions
-
比如官网示例,如何获取到class="item"的所有dom: <FancyList :api-url="url" :per-page="10">
<template #item="{ body, username, likes }">
<div class="item">
<p>{{ body }}</p>
<p>by {{ username }} | {{ likes }} likes</p>
</div>
</template>
</FancyList> <!--FancyList.vue-->
<ul>
<li v-for="item in items">
<slot name="item" v-bind="item"></slot>
</li>
</ul> |
Beta Was this translation helpful? Give feedback.
Answered by
s3xysteak
Jul 31, 2024
Replies: 1 comment
-
<script setup>
const slots = useSlots()
</script> defineComponent((_, { slots }) => {
// slots...
return () => h('div')
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
inside5545
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
playground