laravel vue router not working

Posted 4 months ago by mostafalaravel

Hey there ,

I have some troubles with the router , I cant see the content of any component. The only thing is just the menu but when I click nothing happened !:

here the Welcome blade :

<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Action Follow Up v2</title>

    <!-- Fonts -->

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">

</head>
<body>
<noscript>
    <strong>We're sorry but Action Follow Up v2 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app">
    <nav>
        <router-link to="/">action</router-link>
        <router-link to="/action_details/154">details</router-link>
    </nav>
</div>
<script type="text/javascript" src="/js/app.js"></script>
</body>
</html>

router JS :

import Vue from 'vue'
import Router from 'vue-router'
import actions from './components/actions.vue'
import action_details from './components/action_details.vue'

Vue.use(Router)

export default new Router({
    routes: [
        {
            path: '/',
            name: 'actions',
            component: actions
        },
        {
            path: '/actions/:action',
            name: 'action_details',
            component: action_details
        }
    ]
})

app.js


/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

window.Vue = require('vue');

import axios from 'axios';
Vue.use('axios')

Vue.use(require('vue-moment'));

var Paginate = require('vuejs-paginate')
Vue.component('paginate', Paginate)

import router from './router'

/**
 * The following block of code may be used to automatically register your
 * Vue components. It will recursively scan this directory for the Vue
 * components and automatically register them with their "basename".
 *
 * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
 */

// const files = require.context('./', true, /\.vue$/i)
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))

Vue.component('participations', require('./components/participations.vue').default);

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

const app = new Vue({
    router,
    el: '#app'
});

Thanks

Please sign in or create an account to participate in this conversation.