How is your Laravel routing setup?
Sep 25, 2020
2
Level 2
My Vue Js Route is not working in laravel ?
I have installed Vue router
npm install vue-router
//In package.json
"vue-router": "^3.4.4"
In App.js, I have import like this
import VueRouter from 'vue-router'
Vue.use(VueRouter);
const router = new VueRouter({
routes,
mode: 'hash',
});
//If i remove this then (Unknown custom element: <category>) error will thrown
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
Vue.component('category', require('./categories/CategoryComponent').default);
//Routes
import { routes } from './routes';
const app = new Vue({
el: '#app',
router
});
In route.js
import Dashboard from './components/ExampleComponent'
import Category from './categories/CategoryComponent'
export const routes = [
{
path:'/dashboard',
component:Dashboard
},
{
path:'/categories',
component:Category
},
];
In Category Component
<template>
<router-link to="/dashboard">Dashboard</router-link>
</template>
In the dashboard blade file
@extend('layout.app')
@section('content')
<router-view></router-view>
@endsection
Now my problem is Suppose there is this URL http://127.0.0.1:8000/categories#/ and the page goes to CatergoyComponent and when I click the button Dashboard in CategoryComponent Only Url Change http://127.0.0.1:8000/dashboard#/ but the page remains the same as categories Component. until I refreshed. what did I do wrong?
Please or to participate in this conversation.