Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jacobmischka opened this issue Dec 20, 2016 · 1 comment
Closed

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

jacobmischka opened this issue Dec 20, 2016 · 1 comment

Comments

@jacobmischka
Copy link

jacobmischka commented Dec 20, 2016

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

@ghost
Copy link

ghost commented Apr 2, 2018

Here's what I did, I have an array of object instances of a specific class. That class has public functions in it and I need to invoke those functions on the template. It just seems the v-bind converts the passed value to a standard object. Is there any way I can invoke those class functions in there? Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant