F
F
Friend2021-06-27 02:13:29
Laravel
Friend, 2021-06-27 02:13:29

How to work with Vue and Laravel without vuerouter?

I usually made SPA applications with a Laravel backend using vue-router.
Is it possible to exclude vue-router from this chain, because there are routers in Laravel?

It is necessary that when you click on each sidebar item on the left, another component is loaded as always and data is pulled from the backend. Using vut-router, everything was clear. but how to implement so that when clicking on the sidebar link, the vue
router is not used, but immediately so that a request is sent to the backend and then the component is loaded into the container with the filled data.

I know how everything works. mounted, dispatch, ... But how to do without a router on the client side?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pLavrenov, 2021-06-27
@pLavrenov

Documentation -
Laravel Component Basics - js
You insert a component into the template and everything works.

D
Dmitry, 2021-06-27
@Golosov

Have a look at InertiaJS . By the way, it is used in the JetStream package .
It allows you to make the usual routes in Laravel, while you return InertiaResponse with the data array, and in Vue you get them as props, is this not a miracle.
This is from the InertiaJS description:

...you will use Laravel's router instead of Vue router

Good luck!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question