[Documentation] v-slot:activator="{ on }"
See original GitHub issuehttps://vuetifyjs.com/en/components/tooltips#usage
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon color="primary" dark v-on="on">home</v-icon>
</template>
<span>Tooltip</span>
</v-tooltip>
So I’m guessing that the activator slot in the component binds the data object from the render function so that its available in the parent scope. The data object contains an on
property which includes the event listeners.
It’d be nice for the doc to provide some pointers to the logic and syntax used. A brief comment in the activator slot description with a link to the below url would be nice.
https://vuejs.org/v2/guide/render-function.html#The-Data-Object-In-Depth
_Originally posted by @YuqiaoS in https://github.com/vuetifyjs/vuetify/issues/6823#issuecomment-476560266_
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:46 (14 by maintainers)
Top Results From Across the Web
Meaning of v-slot:activator="{ on }" - Stack Overflow
When I try it in my project, Internet Explorer throws an error on the <template v-slot:activator="{ on }"> , but if I remove...
Read more >Vuejs and Vuetify - what does v-on mean - Desktop Liberation
The activator slot is expecting to receive props, so { on } is just extracting the on property from props, in other words...
Read more >Menu component - Vuetify
The v-menu component shows a menu at the position of the element used ... With the new v-slot syntax, nested activators such as...
Read more >Slots - Vue.js
Dynamic Slot Names #. Dynamic directive arguments also work on v-slot , allowing the definition of dynamic slot names: template
Read more >v-slot:activator with functional top-level component - CodePen
<template v-slot:activator="{ on }">. 4. <v-scroll-x-transition>. 5. 6. <v-btn class="item-panel" icon text v-on="on" v-if="show">.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If we’re looking at this syntax:
and we look at the following
The documentation for scoped slots
The documentation for the
v-on
apiThe documentation for vm.$listeners
The source code for the v-dialog component
I read the above syntax as saying
Expose the
on
event listeners object from the parentv-dialog
component’s activator slot to the child template. Using the v-on object syntax bind all the fields of theon
event listeners object to thev-btn
component’s events. When thev-btn
component is clicked, the function associated with the click field of theon
event listeners object will be called, causing the v-dialog component to become visible.What I think is causing the confusion with the syntax
The combination of the following
v-slot:activator="{ on }"
is exposing the objecton
via object destructuring.on
is itself an object and not something else.on
is coming fromv-on="on"
is leveraging the new v-on object syntax to automatically assign events on thev-btn
component to functions associated with fields of theon
objectIf we rearrange the syntax slightly it is a bit more intuitive what is going on as it only requires knowledge of how slot scopes can pass data to their children by automatically communicating that
on
is an object with aclick
field that is getting associated with thev-btn
click event.This isn’t clear at all. You should add doc to explain what the syntax means.