Skip to content

Commit 4668a15

Browse files
committed
minor #499 [Vue.js] Document events (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [Vue.js] Document events As mentioned in #479 (comment) | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Features and deprecations must be submitted against branch main. --> Added some documentation for events, in order to create a new release (as told in #479 (comment)) Commits ------- b0337cb [Vue.js] Document events
2 parents bb10dcf + b0337cb commit 4668a15

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)