You can do Vue Router and Laravel Router well together by making the following changes:
At the end of your routes/web.php add the following lines:
Route::get('{path}', function() { return view('your-vuejs-main-blade'); })->where('path', '.*');
You need to add this to the end of the file because you need to save the previously declared laravel routes for proper operation and not be overwritten by 404 or vue-router pages.
In the configuration of your Vue router, use the following:
import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) let router = new Router({ mode: 'history',
However, when navigating between laravel and vue-router, you need to keep in mind that when leaving the vue-router page on the laravel page, you must use the window.location.href code, the <a> tag, or some kind of program navigation to exit completely from the Vue-router instance.
Tested with Laravel 5.5.23, Vue 2.5.9, Vue-Router 3.0.1
source share