Skip to content

Commit b0337cb

Browse files
authored
[Vue.js] Document events
As mentioned in #479 (comment)
1 parent bb10dcf commit b0337cb

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/Vue/Resources/doc/index.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,55 @@ For example:
8888
8989
<div {{ vue_component('MyComponent', { 'name': app.user.fullName }) }}></div>
9090
91+
Events
92+
~~~~~~
93+
94+
The event ``vue:before-mount`` is called before a component is mounted on the page. This is the event to listen if you need to modifiy the Vue application (e.g.: add plugins, add global directives, ...):
95+
96+
.. code-block:: js
97+
98+
document.addEventListener('vue:before-mount', (event) => {
99+
const {
100+
componentName, // The Vue component's name
101+
component, // The resolved Vue component
102+
props, // The props that will be injected to the component
103+
app, // The Vue application instance
104+
} = event.detail;
105+
106+
// Example with Vue Router
107+
const router = VueRouter.createRouter({
108+
routes: [
109+
/* ... */
110+
],
111+
});
112+
113+
app.use(router);
114+
});
115+
116+
The event ``vue:before-mount`` is called when a component has been mounted on the page:
117+
118+
.. code-block:: js
119+
120+
document.addEventListener('vue:mount', (event) => {
121+
const {
122+
componentName, // The Vue component's name
123+
component, // The resolved Vue component
124+
props, // The props that are injected to the component
125+
} = event.detail;
126+
});
127+
128+
The event ``vue:unmount`` is called when a component has been unmounted on the page:
129+
130+
.. code-block:: js
131+
132+
document.addEventListener('vue:unmount', (event) => {
133+
const {
134+
componentName, // The Vue component's name
135+
props, // The props that were injected to the component
136+
} = event.detail;
137+
});
138+
139+
91140
Backward Compatibility promise
92141
------------------------------
93142

0 commit comments

Comments
 (0)