PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 2, 2022

[FIXED] Laravel + Vue JS Routing shows page not found

 January 02, 2022     laravel, laravel-5, vue-router, vue.js     No comments   

Issue

I followed this tutorial https://laraveldaily.com/quick-start-laravel-5-5-vue-js-simple-crud-project/

However when I load : localhost/admin/companies , I get page not found .

I tried to change to this too

const router = new VueRouter({
 routes: [
   { path: '/admin/companies', component: CompaniesController }
 ]
})

But I get "Syntax error { " on the part VueRouter({ which I don't understand why. Can anyone help?

Thanks!


Solution

Vue Router doesn't reload the page. Vue Router doesn't work like the Laravel Router. All it does whenever a Vue route changes, it mounts different component to a specific area. This area is defined by predefined router-view element. It mounts the component according to the Vue route changes.

Blade

<div class='box'>
    <router-view name="content-viewport"></router-view>
</div>

Vue

const router = new VueRouter({
  routes: [
    { path: '/admin/companies', components: {"content-viewport" : CompaniesController} }
  ]
});

Now when you go to domain#/admin/companies Vue will mount the component CompaniesController in 'content-viewport'



Answered By - santanu bera
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing