T
T
testopikachu2019-06-19 11:51:46
Vue.js
testopikachu, 2019-06-19 11:51:46

Is it possible to use vue router on a multipage (NOT spa) site in laravel?

Hello, is it possible to somehow use vue router on a multi-page (NOT spa) site on laravel?
Those. for example, on the /admin/categories page, the template of which is generated by laravel, I hook app.js

//app.js
new Vue({
    router,
    mounted() {
        console.log(this.$route.path) // "/"
    }
});

And in my router I have this route
//router.js
const AdminCategories = () => import('./components/admin/categories.vue')
routes: [
  {path: '/admin/categories', component: AdminCategories},
]

But the router does not pick up my path (/admin/categories) and in the mounted() console.log returns "/" - the root.
Accordingly, the AdminCategories component is not loaded

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Darkhan Kamaliev, 2019-06-19
@darakanoit

Something you are not doing. On laravel, all requests should go to one file, in which vue is drawn.
Then a regular vue project with routing.
Or you can combine the classics with vue. Ordinary blade pages with their own vue components.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question