[Vuejs]-Vue 2 Laravel 5.3 Vue-router 2 Proper way to set up Vue-router

0👍

It looks like you aren’t injecting your router into your app, hence it being ‘undefined’

To inject the router make following changes in the Vue app in app.js:

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

After that you can use this.$router throughout the app.


Other approach:

You have to import router from app.js like following:

import router from ‘./path/to/app

and after that you can simply use:

router.push

Leave a comment