Skip to content

[Vue.js] Document events #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/Vue/Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,55 @@ For example:

<div {{ vue_component('MyComponent', { 'name': app.user.fullName }) }}></div>

Events
~~~~~~

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, ...):

.. code-block:: js

document.addEventListener('vue:before-mount', (event) => {
const {
componentName, // The Vue component's name
component, // The resolved Vue component
props, // The props that will be injected to the component
app, // The Vue application instance
} = event.detail;

// Example with Vue Router
const router = VueRouter.createRouter({
routes: [
/* ... */
],
});

app.use(router);
});

The event ``vue:before-mount`` is called when a component has been mounted on the page:

.. code-block:: js

document.addEventListener('vue:mount', (event) => {
const {
componentName, // The Vue component's name
component, // The resolved Vue component
props, // The props that are injected to the component
} = event.detail;
});

The event ``vue:unmount`` is called when a component has been unmounted on the page:

.. code-block:: js

document.addEventListener('vue:unmount', (event) => {
const {
componentName, // The Vue component's name
props, // The props that were injected to the component
} = event.detail;
});


Backward Compatibility promise
------------------------------

Expand Down