Reputation: 367
I'm trying to create a SPA with laravel and vue. Also installed Voyager for admin purposed. Voyager is http://localhost:8000/admin .. which used laravel web route.
Can't access it now i'm using Vue Router for my routes: Example for my Home Route (vue) http://localhost:8000/home
app.js
...
import VueRouter from 'vue-router';
import App from './components/App.vue';
import Home from './components/Home.vue';
Vue.use(VueRouter);
const router = new VueRouter({
mode: 'history',
routes: [
{
path: '/home',
name: 'home',
component: Home
},
],
});
const app = new Vue({
el: '#app',
components: { App },
router,
});
App.vue
<template>
<div>
<h1>Vue Router Demo App</h1>
<p>
<router-link :to="{ name: 'home' }">Home</router-link> |
</p>
<div class="container">
<router-view></router-view>
</div>
</div>
</template>
<script>
export default {}
</script>
Home.vue
<template>
<p>This is the homepage</p>
</template>
index.blade.php
@extends('layouts.app')
@section('content')
<app></app>
@endsection
web.php
Auth::routes();
Route::get('/{vue_capture?}', function () {
return view('index');
})->where('vue_capture', '[\/\w\.-]*');
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
});
Upvotes: 2
Views: 5783
Reputation: 367
ok i solved it!!
exchanging the order of routes declaration in we.
web.php
Auth::routes();
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
});
Route::get('/{vue_capture?}', function () {
return view('index');
})->where('vue_capture', '[\/\w\.-]*');
Upvotes: 5