1👍
This is your original code:
<slot v-bind:user="user">
It’s potentially confusing because there are two things called user
here. The v-bind:user
part is going to create a user
property within the slotProps
object. The other part, ="user"
, just assigns a value to that property. The fact that this value is also coming from a property called user
makes this example somewhat difficult to follow.
For your second example, you could maybe do something like this:
<slot v-bind:user="{ firstName, lastName }">
Note that { firstName, lastName }
is a shorthand for { firstName: firstName, lastName: lastName }
. It’s just creating an object with two properties. The values for those two properties are coming from your data
.
Again this is creating a property called user
within the slotProps
but this time the value is an object that is being created on the fly.