Skip to content

Update Vue docs #504

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 13, 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
37 changes: 36 additions & 1 deletion src/Vue/Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ The event ``vue:before-mount`` is called before a component is mounted on the pa

// Example with Vue Router
const router = VueRouter.createRouter({
history: VueRouter.createWebHashHistory(),
routes: [
/* ... */
],
Expand All @@ -113,7 +114,12 @@ The event ``vue:before-mount`` is called before a component is mounted on the pa
app.use(router);
});

The event ``vue:before-mount`` is called when a component has been mounted on the page:
.. note::
When using Vue Router, you can use "hash" or "memory" history mode
to prevent your Vue routes from being served through Symfony controllers.
If you want to use web history mode, see :ref:`Web History mode with Vue Router`

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

.. code-block:: js

Expand All @@ -136,6 +142,35 @@ The event ``vue:unmount`` is called when a component has been unmounted on the p
} = event.detail;
});

Web History mode with Vue Router
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To use "web" history mode with Vue Router, a catch-all route will be needed
which should render the same template and Vue component:

.. code-block:: php

#Route('/survey/{path<.+>}')
public function survey($path = ''): Response
{
// render the template
}

This controller will catch any URL that starts with `/survey`. This prefix can then be
used for all the Vue routes:

.. code-block:: js

const router = VueRouter.createRouter({
history: VueRouter.createWebHistory(),
routes: [
{ path: '/survey/list', component: ListSurveys },
{ path: '/survey/create', component: CreateSurvey },
{ path: '/survey/edit/:surveyId', component: EditSurvey },
],
});

app.use(router);

Backward Compatibility promise
------------------------------
Expand Down