In my latest project, I decided to create a dynamic dashboard using Laravel and Vue.js. One of the challenges I faced was implementing nested routes using Vue Router:
/admin
/admin/posts
/admin/posts/add
/admin/posts/edit/:id
Despite my efforts, I encountered an issue where switching between /admin/posts and /admin/posts/add didn't route to the correct component. It always redirected me to App.Vue.
Here is a snippet of the code from my web.php file:
Route::get('admin/{any?}', 'App\Http\Controllers\Admin\DashboardController@index')->where('any', '.*');
And here is a section from my app.js file:
(insert your app.js code here)
Code from routes.js:
(insert your routes.js code here)
Snippet from App.vue:
(insert your App.vue code here)
AllPosts.vue content:
(insert your AllPosts.vue code here)
AddPost.vue code:
(insert your AddPost.vue code here)
Thank you for your help!