Skip to content

v-bind="obj" syntax with scoped slot #4529

@jacobmischka

Description

@jacobmischka

I'm trying to make a custom list component using a scoped slot like the one in the docs, and I would like to expose all of the item properties as props to the template. Unfortunately, the v-bind="obj" syntax doesn't seem to be working for me in a scoped slot. Is this deliberate?

Regular v-bind:prop="obj.prop" syntax is working correctly, but it would be great if I could expose everything at once.

I don't believe I'm making a mistake, but sincere apologies if I am, or if this has been mentioned somewhere else that I missed.

Thank you!


Entry point:

<custom-list :items="listItems">
	<template scope="item">
		<li>{{ item }}</li>
	</template>
</custom-list>

CustomList with implicit v-bind object binding:

<template>
	<ul>
		<slot v-for="item of items" v-bind="item"></slot>
	</ul>
</template>

Result:

image

CustomList with explicit prop binding:

<template>
	<ul>
		<slot v-for="item of items" :id="item.id"></slot>
	</ul>
</template>

Result:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions