Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Roni's avatar
Level 33

Access vue variables from slot data

Is there a way to access/update Vue data variable from inside a named slot? Right now I have a vue component working with blade partials in slots, and it would be so convenient if I could have a button that has to be inside the slot, update one of the reactive data variables. Is there a way to emit an event that vue would be listening for from vanilla javascript?

0 likes
3 replies
Roni's avatar
Level 33

thanks @digiproduct, I'll check them out, the award is yours once I find it... Cheers

EDIT...

I haven't watched them yet but reading the titles it seem like those deal with standard events being emitted between vue components. I'm looking at emitting an event from standard vanillaJS on a that being rendered from a blade template that exists in the slot of the vue component. I'd imagine it won't matter since the vue components living in the DOM reside there in a stateless manner, but I won't have access to this.$emit for example, because I'd have to be in vue for that to happen. I only have access in that partial to a simple vanilla onclick event.

DigiProduct's avatar

I thought you needed ... "access/update Vue data variable from inside a named slot"

So isn't it all happening inside Vue?

Please or to participate in this conversation.