Himanshu
Himanshu

Reputation: 57

vue router with vue 2 component not working with laravel 5.8

my vue components are working fine, but when i want it with vue router it unable to find the component

this is the vue error i am getting

app.js code

this is a message i got when i installed vue router

Upvotes: 1

Views: 186

Answers (2)

user10753862
user10753862

Reputation:

Try it with like below.

component: Vue.component("Home", require("./Myhome").default)

You don't need to import it with this way.

Hope it helps.

Upvotes: 1

Karan Sadana
Karan Sadana

Reputation: 1373

The problem is with this code

{path:'home,component:MyHome}

So the reason for the error is, there is no MyHome variable holding any component right. You just register your component with Vue.Component which directly register your component.

Solution

So now for solving this, As Johhn said, Import your component and store it in variable and then pass that variable to your route like below.

import MyHome from "./components/MyHome.vue"

{path:'home,component:MyHome}

Upvotes: 1

Related Questions